ncuillery / angular-breadcrumb

Generate a breadcrumb from ui-router's states
http://ncuillery.github.io/angular-breadcrumb/
MIT License
785 stars 183 forks source link

Dynamic breadcrumb with resolve variable #107

Open Squeezya opened 9 years ago

Squeezya commented 9 years ago

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: {
                    'fase@main.applications.fase': {
                        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 {{ }} ?

bartrail commented 9 years ago

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

vjanssens commented 9 years ago

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'
go4varuntyagi commented 9 years ago

@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??

ismailatkurt commented 8 years ago

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.

nbasov commented 8 years ago

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

Luddinus commented 8 years ago

@ismatkurt Did you find a solution?

soumyart commented 6 years ago

@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.