-
Notifications
You must be signed in to change notification settings - Fork 3k
Unable to inject templateProvider with resolved values #330
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
Comments
Just encountered this issue. I need to determine which template to load by looking at the resolved data. However currently in template provider function I cannot access such information. By the way, in the documentation it mentions that templateProvider can "access to locals", however I could not figure out what this means. |
The reason this works for controller is that the controller is actually instantiated later as a second step, whereas currently |
Thanks for the speedy response! It seems that the controller is the only place we can access resolved data so far. |
I'm not 100% sure this will work, but you should be able to simply have '$template' inside your resolve yourself. It needs to resolve to the loaded template data (not 100% $state won't overwrite that value but give it a try). |
Thanks for the tip. I couldn't get that |
So, #196 has now been implemented, which enables resolve inheritance, but for this to work, This will be difficult to refactor this effectively, because of the number of abstraction boundaries it crosses. |
I have a similar issue where I'd like to load different views/controllers based on a users role. In order for this to work I'd first have to retrieve the roles from the server (most likely as a resolve property) and inject it into the templateProvider and controllerProvider. Only other option is to define two states, one for each role, and redirect accordingly in the state change handler. |
Currently using ui-router 0.2.7 and angular 1.2.6. Currently getting started with angular. I've been debugging what was going on in a UI with multiple named and abstract views. One of the views had a templateProvider fn that returned the template based on resolve values (amidst 8 other values). I didn't know to search for this issue because the templateProvider fn fails silently and I thought the problem was in another part of the code. Is this failing silently because the return value here is null? I'd be happy to PR an error message if that's a good spot to include it. |
@a-laughlin Yeah, agreed. Thanks. |
Cool. It's going to be a few days before I'll be able to get to it, but I'll send a PR when done. |
Any idea when this will be fixed. Or what is the way around it? |
Unfortunately time has been sparse and this is a low priority. I haven't tested it as thoroughly as I'd like, but wanted to follow through on the pull request offered in angular-ui#330 (comment). Hopefully this will help others trying the same thing and getting silent errors.
This issue still persists. I have a route that defines a resource that can be of 3 different types, I don't know the type until I resolve getting data from the db and then I can select which is the correct view and controller. Is this planned for fixing? |
Guys please fix that, its very important part |
+1 |
1 similar comment
+1 |
I'l fix it when I have time. In the meantime, you're welcome to submit a PR. |
Hey guys, |
+1 |
bah, sorry, i made a comment on the wrong issue! |
Works like a charm thanks for improving on this. #1934 |
A view's
templateProvider
is unable to be injected with resolved values. The following will fail with an error likeError: [$injector:unpr] Unknown provider: barProvider <- bar
.I see in
resolveState
that$view.load
only gets some locals to inject. Is there any technical reason whytemplateProvider
couldn't be injected with all of the resolve values in the same way thatcontroller
is?(This is on git master, and I remember seeing the same limitation a couple of months ago.)
The text was updated successfully, but these errors were encountered: