Open haddadr opened 8 years ago
+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.
+1
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.
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)
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