码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular2 Router] Redirects and Path Matching - Avoid Common Routing Pitfall

时间:2016-10-03 00:08:08      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

In this tutorial we are going to learn how we can can configure redirects in the angular 2 router configuration. We are also going to see again another example on how the order of the configuration might trip us. We are going to see the different between path matching in prefix mode vs full mode, and we are going to learn why redirects should be in general configured using full path matching.

 

{path: ‘legacy-url‘, redirectTo: ‘/home‘, pathMatch: ‘full‘},

pathMatch: ‘full‘ : only match ‘legacy-url‘, won‘t match ‘legacy-url/1‘;

 

{path: ‘legacy-url‘, redirectTo: ‘/home‘, pathMatch: ‘prefix‘},

pathMatch: ‘prefix‘ : not only match ‘legacy-url‘, but also match ‘legacy-url/1‘;

 

Notice, this redirectTo should be define on the top of other routers.

[Angular2 Router] Redirects and Path Matching - Avoid Common Routing Pitfall

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5928254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!