简体   繁体   中英

AngularJS $rootScope.$broadcast

How to know $broadcast in AngularJS, have success response or unsuccess response

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

From the documentation :

$broadcast(name, args);

Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.

The event life cycle starts at the scope on which $broadcast was called. 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.

So, the answer to your question:

How to know $broadcast in AngularJS, have success response or unsuccess response

is to catch exceptions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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