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

Dynamic breadcrumb with resolve variable

Open Squeezya opened this issue 10 years ago • 7 comments

hi, im not sure if i am doing this right but... I have this state:

.state('main.applications.fase.utilizador.show', {
                url: '/:idUser',
                resolve: {
                    user: ['$state', '$stateParams', 'User',
                        function ($state, $stateParams, User) {
                            return User.getFromDB($stateParams.idUser, {
                                'fromAD': false,
                                'include': 'aluno,aluno.escolas,aluno.cursos,aluno.anosLetivos'
                            }).then(function (user) {
                                return user;
                            })
                        }]
                },
                views: {
                    '[email protected]': {
                        templateUrl: 'app/applications/fase/utilizador/show.html',
                        controller: 'app.applications.fase.UtilizadorCtrl',
                        controllerAs: 'vm'
                    }
                },
                ncyBreadcrumb: {
                    label: 'app.fase.perfil.label'
                }
            });

And I want the label to be the user.id (user is on resolve) is it possible to do this? Use the resolve variables to dynamically do the ncy label?

Another thing, if i use controller as vm how can i use scope to make a dynamic label with {{ }} ?

Squeezya avatar Sep 14 '15 17:09 Squeezya

+1 - I need custom labels, depending on the received data

bartrail avatar Sep 16 '15 18:09 bartrail

This should be possible by setting {{ vm.user.id }} as the label. Unfortunately, in my case, this does not work when you refresh the page. The label will remain empty (this seems like a bug but I haven't reproduced this in a plunkr). So this will only work when you click from another page to /:idUser page.

Another possibility is to update the label in your controller, by doing:

$state.current.ncyBreadcrumb.label = 'Your custom breadcrumb here'

vjanssens avatar Sep 25 '15 08:09 vjanssens

@vjanssens : Even $state.current.ncyBreadcrumb.label is also behaving similarly. It do not change the label first time but when you come second time on the same page.

Any one able to get this fixed??

go4varuntyagi avatar Oct 28 '15 15:10 go4varuntyagi

As I mentioned here probably the reason is related to $interpolate.

Is there anyone that has figured out the solution. I'm trying a few things but couldn't find any solution yet.

ismailatkurt avatar Dec 02 '15 09:12 ismailatkurt

Here is an old issue about this problem https://github.com/ncuillery/angular-breadcrumb/issues/42 Solved by injecting $breadcrumb into application .run method.

nbasov avatar Mar 16 '16 12:03 nbasov

@ismatkurt Did you find a solution?

Luddinus avatar Sep 10 '16 22:09 Luddinus

@go4varuntyagi : I used both

$state.current.ncyBreadcrumb.label = 'Your custom breadcrumb here';
$state.current.ncyBreadcrumbLabel = 'Your custom breadcrumb here';

Instead of only $state.current.ncyBreadcrumb.label = 'Your custom breadcrumb here' and it worked.

soumyart avatar Dec 19 '17 06:12 soumyart