Open thebigredgeek opened 9 years ago
Bump?
Hi,
Apologies for the delay, I'll throw an eye on it soon :angel:
Hi, apologies for the delay since my last apologies :smile:
I think you did a great job here. If I understand well, it can be used by defining ncyBreadcrumb.label
as a DI function or array like this:
.state('room.detail.edit', {
url: '/edit',
views: {
"@" : {
templateUrl: 'views/room_form.html',
controller: 'RoomDetailCtrl'
}
},
ncyBreadcrumb: {
label: function(rooms, $stateParams) {
for(var index = 0; index < rooms.length; index++) {
if(rooms[index].roomId === parseInt($stateParams.roomId)) {
return 'Editing room ' + rooms[index].roomNumber;
}
}
return 'Editing';
}
}
});
It's a flexible way of defining a label and could be a workaround for the problem described here #89, right ?
I have a suggestion: We can easily make the current scope (the one attached to the $viewContentLoaded
event, used by all the directives) available for DI by using the third arg locals
of $injector.invoke
(see docs):
step.ncyBreadcrumbLabel = $injector.invoke(
step.ncyBreadcrumb.label,
undefined,
{'$scope': viewScope});
Then you can inject the scope:
ncyBreadcrumb: {
label: function($scope, rooms, $stateParams) {
[...]
}
}
It could be useful if other situations, when the current scope hold desired informations. What you think ?
I could be great if we harmonize the syntax with the ncyBreadcrumb.parent
where I "inject" the current scope manually here (I can do it later if you prefer, you paved the path here)
Hello, Any idea if this is going to be merged or if there is a workaround ? Thanks
Anyone have a status update on this?
+1 Would really like this feature.
This allows more dynamic use of the label. Right now, the label is bound to the parent scope, even if the parent scope is destroyed (such as in the case that the child state is interpolated into the same view as the parent state was contained in). This breaks the breadcrumbs, as the label can no longer interpolate properties from the controller attached to it's state because the controller has been destroyed (as well as the scope).