X Tutup
Skip to content

feat(angular_1_router): route to directives instead of controllers#4266

Closed
btford wants to merge 5 commits intoangular:masterfrom
btford:feat-router-angular-1-route-to-directives
Closed

feat(angular_1_router): route to directives instead of controllers#4266
btford wants to merge 5 commits intoangular:masterfrom
btford:feat-router-angular-1-route-to-directives

Conversation

@btford
Copy link
Copy Markdown
Contributor

@btford btford commented Sep 18, 2015

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' }
])

This is a pretty significant refactor, so I'd like to land it ASAP.

Also addresses #4184, #3993.

@btford btford added feature Label used to distinguish feature request from other issues comp: router effort2: days labels Sep 18, 2015
@btford btford added this to the alpha-38 milestone Sep 18, 2015
@IgorMinar
Copy link
Copy Markdown
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.

@btford
Copy link
Copy Markdown
Contributor Author

btford commented Sep 19, 2015

Great. Thanks so much, @IgorMinar!

@shahata
Copy link
Copy Markdown

shahata commented Sep 19, 2015

Also did a quick review and added some comments. Generally looks good, I really like the idea of ngRouteShim.

@shahata
Copy link
Copy Markdown

shahata commented Sep 19, 2015

Comments are here: btford@011205e

@btford btford force-pushed the feat-router-angular-1-route-to-directives branch from 07e71bf to ef95e65 Compare September 21, 2015 18:08
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.
@btford btford force-pushed the feat-router-angular-1-route-to-directives branch 3 times, most recently from e522cf0 to b1ffe68 Compare September 21, 2015 19:13
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.
@btford btford closed this in aed34e1 Sep 21, 2015
@btford
Copy link
Copy Markdown
Contributor Author

btford commented Sep 21, 2015

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
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes effort2: days feature Label used to distinguish feature request from other issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup