-
Notifications
You must be signed in to change notification settings - Fork 183
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
label function support #63
Comments
Have you faced a situation where you could have need this feature? I ask myself if this feature could be useful because the label can already be a expression calling a function in the scope: // config
$stateProvider.state('main', {
[...],
ncyBreadcrumb: {
label: '{{getBreadcrumbLabel()}}'
}
})
// controller
$scope.getBreadcrumbLabel = function() {
// Something with scope here
} Anyway, thanks for the suggestion. |
Yes, when having multiple views it binds to every scope of every view, which is wrong. -----Original Message----- Have you faced a situation where you could have need this feature? // controller |
OK, it could be a nice feature for v0.4.x |
Hi, I was wondering the same thing. And I tried what you suggested @ncuillery, passing a scope function to the label, but it doesn't display what I return. Here's a quick example, maybe I'm doing something wrong: http://plnkr.co/edit/Uj8RTNqbPNKx9q9cHohp Thanks for looking into it. |
Ok, after a bit of search, I'm logging line 211, It goes like so: So I guess that because the last run gives an empty response, that's why my code isn't showing. But don't know why... |
It is perhaps worth noting that using the above approach, I was only able to output the function after injecting $rootScope into the controller. So,
would become:
|
I would also see the use for having a function for label. Basically, I've got states that have have a parent state with a dynamic label. Home > user name > current state "user name" would be a state such as "site.user({id: 12})", and I would like in the label function to be able to perform a backend query to get the name of the user and output it there. While it's true the backend query can be done in the current state and some scope var can be set to print the user name, I would prefer if the current state didn't have to handle that. I would like each state to handle its own labeling. |
I guess ideally, I would like to have a breadCrumb builder like: .state('site.users', { url: '/users/{id:[0-9]+}', templateUrl: 'users.html', controller: 'UsersController', ncyBreadcrumb: { builder: function($injector, $state) { var someService = $injector.get('someService'); var $q = $injector.get('$q'); var deferred = $q.defer(); someService($state.params.id).then(function(result) { deferred.resolve({ label : result.label, parent : result.parent }); } return deferred.promise; } } }) In the meantime, I've been thinking of using the getStatesChain function and at each state update, run some function on each state to build its label (at least for the states that have a dynamic label). |
this would be helpful, i have multiple controllers using the same state and in order to render their own custom breadcrumbs I have to attach the same function in each controller vs being able to pass in a provider or service
if there way I can accomplish this? |
+1 ng-breadcrumbs seems to support it: https://github.com/ianwalter/ng-breadcrumbs#adding-dynamic-route-labels. |
+1 |
+1 for ability to use |
+1 |
Related to #105 |
Also related to #146 |
It should work exactly the same way as
parent
The text was updated successfully, but these errors were encountered: