Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic label management #156

Open
haddadr opened this issue Jul 12, 2016 · 4 comments
Open

Dynamic label management #156

haddadr opened this issue Jul 12, 2016 · 4 comments

Comments

@haddadr
Copy link

haddadr commented Jul 12, 2016

It will be better to have the possibility to manage the value of the label by a function defined in the route config like below:
ncyBreadcrumb: {
label: function ($scope) {
if ($scope.suiteNumber){
return 'suite';
}else{
return 'room';
}
},
parent: function ($scope) {
return $scope.from || 'room';
}
}

Then all the logic will be in the route config rather than in the controller.
It will result in more readable and maintenable code in both route config and controller source files

@bencpeters
Copy link

bencpeters commented Aug 24, 2016

+1

My use case is that in my app some users view pages that belong to users where the label is dependent on context (e.g. an ancestor state might be "My Profile" vs. "Username Profile"). In cases like this, the parent argument resolves differently, but unless all child controllers are very standardized in how they handle certain $scope variables, it can be difficult to properly resolve this conditional just using angular templating in a label argument.

@Shyam-Echidna
Copy link

+1

@sebastienvermeille
Copy link

Do you have a workaround for now ? I would like to display :

users > $username > profile <--- $username is returned from a resolve. It is really a must. Hope someone can implement it.

@sebastienvermeille
Copy link

Okay well for now I fixed it... (tricky) like that. Maybe it can help someone for now.

I wanted this feature: my controller can update the last breadcrumb label dinamically

  1. In my breadcrumb template I setted an id to the last breadcrumb label :
    <span ncy-breadcrumb-last id="breadcrumb-last"></span>

  2. Then in my controller I defined an updateBreadcrumb method :
    ` function updateBreadcrumb(){

     // Update dynamically the breadcrumb label for this
     // source: https://github.com/ncuillery/angular-breadcrumb/issues/107#issuecomment-143161637
     $state.current.ncyBreadcrumb = {
        label: vm.user.lastname + " " + vm.user.firstname
     };
     var element = angular.element($('#breadcrumb-last'));
     element.html($state.current.ncyBreadcrumb.label);
  }`

Hope this help someone. (We use this till we upgrade to angular2 so it's acceptable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants