Skip to content

Refactor router recognition and redirects#5475

Closed
btford wants to merge 3 commits into
angular:masterfrom
btford:refactor-router-recognition-and-redirects
Closed

Refactor router recognition and redirects#5475
btford wants to merge 3 commits into
angular:masterfrom
btford:refactor-router-recognition-and-redirects

Conversation

@btford
Copy link
Copy Markdown
Contributor

@btford btford commented Nov 25, 2015

Round 2:

This was previously reviewed by @matsko and committed by @alxhub, but it had to be reverted because issues with internal apps.

This includes reverts for the original two non-problematic commits, and a revised third and final commit that includes fixes to the problem that necessitated the roll-back.

@btford btford added action: merge The PR is ready for merge by the caretaker comp: router labels Nov 25, 2015
@btford btford added this to the beta-00 milestone Nov 25, 2015
@btford btford force-pushed the refactor-router-recognition-and-redirects branch 3 times, most recently from 092f416 to 9e3ab04 Compare November 25, 2015 21:51
@mary-poppins
Copy link
Copy Markdown

Merging PR #5475 on behalf of @vsavkin to branch presubmit-vsavkin-pr-5475.

@mary-poppins
Copy link
Copy Markdown

Merging PR #5475 on behalf of @vsavkin to branch presubmit-vsavkin-pr-5475.

This is a big change. @matsko also deserves much of the credit for the implementation.

Previously, `ComponentInstruction`s held all the state for async components.
Now, we introduce several subclasses for `Instruction` to describe each type of navigation.

BREAKING CHANGE:

Redirects now use the Link DSL syntax. Before:

```
@RouteConfig([
	{ path: '/foo', redirectTo: '/bar' },
	{ path: '/bar', component: BarCmp }
])
```

After:

```
@RouteConfig([
	{ path: '/foo', redirectTo: ['Bar'] },
	{ path: '/bar', component: BarCmp, name: 'Bar' }
])
```

BREAKING CHANGE:

This also introduces `useAsDefault` in the RouteConfig, which makes cases like lazy-loading
and encapsulating large routes with sub-routes easier.

Previously, you could use `redirectTo` like this to expand a URL like `/tab` to `/tab/posts`:

@RouteConfig([
	{ path: '/tab', redirectTo: '/tab/users' }
	{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }

Now the recommended way to handle this is case is to use `useAsDefault` like so:

```
@RouteConfig([
	{ path: '/tab', component: TabsCmp, name: 'Tab' }
])
AppCmp { ... }

@RouteConfig([
	{ path: '/posts', component: PostsCmp, useAsDefault: true, name: 'Posts' },
	{ path: '/users', component: UsersCmp, name: 'Users' }
])
TabsCmp { ... }
```

In the above example, you can write just `['/Tab']` and the route `Users` is automatically selected as a child route.

Closes angular#4728
Closes angular#4228
Closes angular#4170
Closes angular#4490
Closes angular#4694
Closes angular#5200
@btford btford force-pushed the refactor-router-recognition-and-redirects branch from 9e3ab04 to 520af55 Compare November 30, 2015 16:34
@mary-poppins
Copy link
Copy Markdown

Merging PR #5475 on behalf of @vsavkin to branch presubmit-vsavkin-pr-5475.

@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

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants