首页 > 代码库 > [Angular2 Router] Redirects and Path Matching - Avoid Common Routing Pitfall
[Angular2 Router] Redirects and Path Matching - Avoid Common Routing Pitfall
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。