zoukankan      html  css  js  c++  java
  • [Angular2 Router] Redirects and Path Matching

    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.

  • 相关阅读:
    清除cookie
    判断是否为中文
    正则表达式
    smarty基础语法
    smarty模板
    ajax
    php工作笔记1
    PHP中超全局变量$GLOBALS和global的区别
    SQL连表查询
    linux上安装git(客户端)及GitHub的配置
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5928254.html
Copyright © 2011-2022 走看看