feat(angular_1_router): route to directives instead of controllers#4266
Closed
btford wants to merge 5 commits intoangular:masterfrom
Closed
feat(angular_1_router): route to directives instead of controllers#4266btford wants to merge 5 commits intoangular:masterfrom
btford wants to merge 5 commits intoangular:masterfrom
Conversation
Contributor
|
I did a quick review. The biggest concern is #4266 (comment), otherwise the rest needs some cleanup but looks generally ok. Sorry, but I can't do an in-depth review now. It would be good for @matsko or @shahata to also take a look. |
Contributor
Author
|
Great. Thanks so much, @IgorMinar! |
This was referenced Sep 19, 2015
b38d740 to
07e71bf
Compare
|
Also did a quick review and added some comments. Generally looks good, I really like the idea of ngRouteShim. |
|
Comments are here: btford@011205e |
07e71bf to
ef95e65
Compare
This is to make way for a refactor to the ng 1.x router directives, which will use strings rather than controller functions in route configs.
e522cf0 to
b1ffe68
Compare
BREAKING CHANGE:
Previously, route configuration took a controller constructor function as the value of
`component` in a route definition:
```
$route.config([
{ route: '/', component: MyController }
])
```
Based on the name of the controller, we used to use a componentMapper service to
determine what template to pair with each controller, how to bind the instance to
the $scope.
To make the 1.x router more semantically alligned with Angular 2, we now route to a directive.
Thus a route configuration takes a normalized directive name:
```
$route.config([
{ route: '/', component: 'myDirective' }
])
```
BREAKING CHANGE:
In order to avoid name collisions, lifecycle hooks are now prefixed with `$`. Before:
```
MyController.prototype.onActivate = ...
```
After:
```
MyController.prototype.$onActivate = ...
```
Same for `$canActivate` (which now lives on the directive factory function),
`$canDeactivate`, `$canReuse`, and `$onDeactivate` hooks.
This module attempts to provide a shim for `$routeProvider` to aid in migrating from ngRoute to Component Router.
Contributor
Author
|
I've addressed comments and made a bunch of the suggested fixes. I'm going to merge this now. |
robwormald
pushed a commit
to robwormald/angular
that referenced
this pull request
Sep 25, 2015
This module attempts to provide a shim for `$routeProvider` to aid in migrating from ngRoute to Component Router. Closes angular#4266
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, route configuration took a controller constructor function as the value of
componentin a route definition:Based on the name of the controller, we used to use a componentMapper service to
determine what template to pair with each controller, how to bind the instance to
the $scope.
To make the 1.x router more semantically alligned with Angular 2, we now route to a directive.
Thus a route configuration takes a normalized directive name:
This is a pretty significant refactor, so I'd like to land it ASAP.
Also addresses #4184, #3993.