简体   繁体   中英

which is best to use $rootScope.$emit or $$rootScope.$broadcast for angularjs loader indicator in angularjs

$rootScope.$emit flows up to $rootScope and $rootScope.$broadcast flows down the scope to $rootScope and all $scope's in angularjs. I am still confused of what exactly to use for angularjs loader indicator .

$rootScope.$emit only lets other $rootScope listeners catch it. This is good when you don't want every $scope to get it.

$rootScope.$broadcast is a method that lets pretty much everything hear it.

This might help, You can refer to the original answer from here

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