[英]ui.router nested States, nested Views: $rootScope.$on $rootScope.$broadcast doesnt connect
i use $rootScope to send data to a controller from a nested state and view 我使用$ rootScope从嵌套状态和视图向控制器发送数据
It works between 'items' and rootSelector, It does not work between 'detail' and rootSelector 它在'items'和rootSelector之间起作用,在'detail'和rootSelector之间不起作用
something blocks my rootScope events. 某些东西阻止了我的rootScope事件。
var listState = {
name: 'playlist.list',
parent: 'playlist',
url: '/list?',
resolve: {
playlistsDb: resolvePlaylistsFromDb,
},
views: {
// target the unnamed view in the playlist state
'@playlist': {
templateUrl: 'app/playlists/list/list.html',
controller: 'PlaylistListController',
controllerAs: 'list'
},
// target the content view in the playlist.list state
'content@playlist.list': {
templateUrl: 'app/playlists/list/items/items.html',
controller: 'PlaylistItemsController',
controllerAs: 'items'
},
// target the rootSelector view in the playlist state
'rootSelector@playlist.list': {
templateUrl: 'app/selector/rootSelector.html',
controller: 'rootSelectorController',
controllerAs: 'rootSelector',
resolve: {
selectedPlaylistId: resolveSelectedPlaylistId,
}
}
}
};
I can send and receive events via $rootScope.broadcast and $scope.$on from PlaylistItemsController "items" to rootSelector 我可以通过$ rootScope.broadcast和$ scope。$ on从PlaylistItemsController“ items”发送和接收事件到rootSelector
but i can't receive them if they come from the nested "detailState" 但如果它们来自嵌套的“ detailState”,我将无法收到它们
var detailState = {
name: 'playlist.list.detail',
parent: 'playlist.list',
url: '/detail/:id',
views: {
'detail@playlist.list': {
templateUrl: 'app/playlists/list/detail/detail.html',
controller: 'PlaylistDetailController',
controllerAs: 'detail',
resolve: {
playlistDb: resolvePlaylistDb,
}
}
}
};
Ok, events didnt go through cause 好的,事件没有通过原因
$scope.$on('removeTrackFromPlaylist'), function (event, args) { }
was no code error in VS2015 VS2015中没有代码错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.