ui.router nested States, nested Views: $rootScope.$on $rootScope.$broadcast doesnt connect

35 Views Asked by At

i use $rootScope to send data to a controller from a nested state and view

It works between 'items' and rootSelector, It does not work between 'detail' and rootSelector

something blocks my rootScope events.

  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
            '[email protected]': {
                templateUrl: 'app/playlists/list/items/items.html',
                controller: 'PlaylistItemsController',
                controllerAs: 'items'
            },


            // target the rootSelector view in the playlist state
            '[email protected]': {
                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

but i can't receive them if they come from the nested "detailState"

 var detailState = {
        name: 'playlist.list.detail',
        parent: 'playlist.list',
        url: '/detail/:id',
        views: {
            '[email protected]': {
                templateUrl: 'app/playlists/list/detail/detail.html',
                controller: 'PlaylistDetailController',
                controllerAs: 'detail',
                resolve: {
                    playlistDb: resolvePlaylistDb,                   
                }
            }
        }
    };
1

There are 1 best solutions below

0
Georg T On

Ok, events didnt go through cause

 $scope.$on('removeTrackFromPlaylist'), function (event, args) { }

was no code error in VS2015