-
Notifications
You must be signed in to change notification settings - Fork 184
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
Added support to use ncyBreadcrumb.label as an injector block #105
base: master
Are you sure you want to change the base?
Conversation
7370aa3
to
9ef4915
Compare
Bump? |
Hi, Apologies for the delay, I'll throw an eye on it soon 👼 |
Hi, apologies for the delay since my last apologies 😄 I think you did a great job here. If I understand well, it can be used by defining .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 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 |
lastStep.ncyBreadcrumbLabel = $injector.invoke(lastStep.ncyBreadcrumb.label); | ||
} else { | ||
var parseLabel = $interpolate(lastStep.ncyBreadcrumb.label); | ||
lastStep.ncyBreadcrumbLabel = parseLabel(viewScope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this directive, we directly assign the variables to the scope of the directive.
scope.ncyBreadcrumbLabel = parseLabel(viewScope);
The same above (L273).
It's the cause of the test failure 😄
Hello, |
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).