简体   繁体   English

AngularJS $ rootScope。$ broadcast

[英]AngularJS $rootScope.$broadcast

How to know $broadcast in AngularJS, have success response or unsuccess response 如何在AngularJS中知道$broadcast ,有成功响应还是不成功响应

$rootScope.$broadcast($scope.abc + ':' + type + 'question', {
    abcSlug: $scope.abcSlug,
    questionSlug: questionSlug,
    abcObj: $scope.abcObj
})

From the documentation : 文档中

$broadcast(name, args); $ broadcast(name,args);

Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners. 向所有子范围(及其子范围)向下分配事件名称,通知已注册的$ rootScope.Scope侦听器。

The event life cycle starts at the scope on which $broadcast was called. 事件生命周期始于调用$ broadcast的范围。 All listeners listening for name event on this scope get notified. 在此作用域上侦听名称事件的所有侦听器都会收到通知。 Afterwards, the event propagates to all direct and indirect scopes of the current scope and calls all registered listeners along the way. 然后,事件传播到当前作用域的所有直接和间接作用域,并在此过程中调用所有已注册的侦听器。 The event cannot be canceled. 该事件无法取消。

Any exception emitted from the listeners will be passed onto the $exceptionHandler service. 侦听器发出的任何异常都将传递到$ exceptionHandler服务。

So, the answer to your question: 因此,您的问题的答案:

How to know $broadcast in AngularJS, have success response or unsuccess response 如何在AngularJS中知道$ broadcast,有成功响应还是不成功响应

is to catch exceptions 捕捉异常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM