angular-breadcrumb icon indicating copy to clipboard operation
angular-breadcrumb copied to clipboard

Why toParams.ncyBreadcrumbLabel is undefined inside a run block?

Open josoroma-zz opened this issue 9 years ago • 1 comments

Hi!

I am trying to create/mimic a kind of custom stack for the current breadcrumbs behavior, but I notice that toParams.ncyBreadcrumbLabel is always undefined even if console.log(toParams) displays its value.

.run(['$rootScope', '$state', '$stateParams', '$breadcrumb', '$templateCache',
function run ($rootScope, $state, $stateParams, $breadcrumb, $templateCache) {
    $rootScope.statesStack = [];

    $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
        $rootScope.statesStack.push({
            'toState': toState,
            'toParams': toParams,
            'fromState': fromState,
            'fromParams': fromParams,
            'fromLabel': toParams.ncyBreadcrumbLabel
        });

        console.log('run - $rootScope.statesStack', $rootScope.statesStack);
    });
}]);

Any help would be great!

josoroma-zz avatar May 31 '16 19:05 josoroma-zz

Hello!

I can confirm the issue @josoroma is experiencing – it seems run blocks are only aware of the pre-resolved param ncyBreadcrumb despite console.log(toState) being able to see the entire resolved params (such as ncyBreadcrumbLabel).

I thought I might be able to mitigate it in a dirty way by using the $interpolate service in my run block to parse the label manually, but it doesn't have access to the proper scope to pull it off.

Any thoughts on where it's hiding? So far I haven't had any luck "promise-ing" it in either.

wosevision avatar Aug 05 '16 19:08 wosevision