-
Notifications
You must be signed in to change notification settings - Fork 3k
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
idea - bind resolved data to controller #2175
Comments
I think it might be harder then you think it is. Have you looked to see if the feature-1.0 branch does this yet? If not, you can try taking a stab at it to see if its possible. |
If you're writing ES6, you can just do |
I am, but I'm want to remove the need to even to that. It'll probably look like that:
The angular.noop + controllerAs might be dropped if the resolve params are added to the created $scope. I'll fork and try to do achieve it. Will update so you guys can decide wether it fits the main branch or not. Worst case I'll stick to the fork :) |
You could probably combine |
Huh, I thought I commented already... I think the idea behind this request is reasonable. I've considered something very similar myself. This is something we may want to consider post-1.0 |
I'd love to see this make it in too. I think a |
👍 |
In 1.0, resolves are now much lazier than they are in 0.2.15. For example, if a resolve is defined but never requested for injection, the resolve fn may never be called (we're calling this the "JIT" resolve policy). We'd have to decide on some rules for behavior. In 1.0, we've got a few building blocks that could help implement this idea: I think we could expose the ResolveContext object as an injectable object for all the ui-router injection points (similar to $stateParams), then let the callers explicitly use the resolve data. I think I'd prefer this over another configuration option Perhaps something like this:
Another possible approach would be to resolve everything (even JIT resolves) if |
summon @nateabele @wesleycho @eddiemonge |
Concur 100%.
I think I'd prefer a structure that involved less repetition, but that's sort of a minor thing. |
I feel like users should explicitly choose to bind data in the controller.
|
+1 |
I would like to add that if one is using TypeScript, one can easily bind to the controller by declaring IMO this shouldn't be supported in the library itself. UI Router is already very config heavy, and adding more minor config bloats up the library with what is supported & can potentially hurt extendibility down the road. |
+1 |
-1 on this. It would be better to just export
Check documentation for angular 1.5 for details: https://code.angularjs.org/1.5.0/docs/guide/component#components-as-route-templates |
+1 for @fesor |
dear @GabiGrin perhaps something like this will do the trick
And you will have in $stateParams the data you required. |
I'm trying to make everything in my app a component(directive), and resolve as much as possible in the ui-router state, to ensure the component has all it needs when the state is loaded.
This is an example of what I'm referring to:
I find my self needing to repeat the
this.data = data
,this.type = type
parts for almost all my states.I think that supporting a
bindToController
option, that will insert resolved data in the controller will be helpful here, similar to a directive's definition object.What do you guys think? if this sounds right I can even try to implement it, as it looks like a simple addition.
The text was updated successfully, but these errors were encountered: