0
我有使用參數的UI路由器狀態:
.config(function config($stateProvider) {
$stateProvider.state('editor', {
url: '/{userName}/{presentationTitle}/editor',
views: {
"main": {
controller: 'EditorCtrl',
templateUrl: 'editor/editor.tpl.html'
}
},
data:{ pageTitle: 'Editor' }
});
})
狀態控制器EditorCtrl使用$在某些時候播出,以指示所涉及的指令,所有數據都已加載。
$scope.$broadcast("allDataLoaded");
,當然還有在指令聽衆:
scope.$on("allDataLoaded", function() { do something })
,一切工作正常的第一次。然後再從具有不同參數的指令中調用相同的狀態:presentationTitle已更改。
$state.go('editor', {presentationTitle:newValue});
而這一次的廣播沒有工作給我很大的驚喜。 EditorCtrl代碼執行時,它到達$ broadcast的行,然後監聽器突然不再響應。
缺少什麼我在這裏?
感謝。當我爲超時設置20毫秒時,這解決了我的問題。 – tjfdfs 2016-04-22 06:17:57