文章詳情頁
angular.js - $emit(,)的具體意思是什么作用呢?
瀏覽:171日期:2024-09-20 13:41:59
問題描述
這個請求接口在success的$scope.$apply()語法后,有這段代碼,具體是啥意思呢?
問題解答
回答1:作用就是告訴他的父級$scope,有事件觸發啦,事件的名字叫做boyslist,然后數據是result.data
如果你的父$scope上有監聽這個事件的話,就會觸發里面的回調函數,例如
$scope.$on(’boyslist’, console.log);
這樣就會打印出來
Scope Events PropagationScopes can propagate events in similar fashion to DOM events. The event can be broadcasted to the scope children or emitted to scope parents.
具體可以看這個,然后看Scope Events Propagation那一小塊
回答2:向父級controller傳遞子controller數據
排行榜
