-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(ngView): reference resolved locals in scope #13400
Conversation
In a nutshell I tried to write a new application with using only module.component and avoiding standalone controllers and ended up writing something like: $routeProvider.when('/', {
template: '<my-app items="resolve.items" />',
resolve: {items: ($http) => $http.get(…)},
controllerAs: 'resolve',
controller: function (items) { this.items = items; }
}); It is pretty ugly that I need to define the controller only so I can get the resolve results in the template... $routeProvider.when('/', {
template: '<my-app items="resolve.items" />',
resolve: {items: ($http) => $http.get(…)}
}); |
@@ -120,6 +120,26 @@ describe('ngView', function() { | |||
}); | |||
|
|||
|
|||
it('should use default resolve controller when resolve map defined with no controller', function() { |
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.
The test description is kibd of undescriptive (I wouldn't have guessed what's supposed to do just by reading the description).
How about a |
@petebacondarwin sure, that makes sense. I'll update the PR. Do you prefer resolvesAs over resolveAs? For me the second sounds better, but maybe that's my broken English :) |
Right, so the property that we are aliasing is |
Added |
this will make it easier to use ng-route with component pattern by being able to configure something like `$routeProvider.when('/', {resolve: {items: ($http) => $http.get(...)}, template: '<my-app items="$resolve.items" />'});` and not having to configure a dummy controller that puts the resolved values on the scope.
oh, I read your original comment again. You mean that this functionality will work only if the route has |
I didn't realise that this had nothing to do with How about:
Then that would mean that a default controller is created that contains all the resolves as properties.
In this second case the resolves would not be bound to the specified controller. Then the most simple case is that neither
|
Actually looking at the actual code of the PR - I think that this is good as it is. Let's merge! |
There should be docs for this feature right ? |
Agh! Good point @gkalpak |
… on scope Relate to angular#13400.
… on scope Related to angular#13400.
… on scope Related to angular#13400.
… on scope Related to angular#13400.
this will make it easier to use ng-route with component pattern by being able to configure something like
$routeProvider.when('/', {resolve: {items: ($http) => $http.get(...)}, template: '<my-app items="resolve.items" />'});
and not having to configure a dummy controller that puts the resolved values on the scope.