在路由时传递数据

1. 在查询参数中传递数据

  1. /product?id=1&name=2 => ActivatedRoute.queryParams[id]

2.在路由路径中传递数据

  1. {path:/product/:id} => /product/1 => ActivatedRoute.params[id]

3. 在路由配置中传递数据

  1. {path:/product, component: ProductComponent, data:[{isProd:true}]} => ActivatedRoute.data[0][isProd]

重定向路由

  1. const routes:Routes = [
  2. {path: '', redirectTo: '/home', pathMatch: 'full'}
  3. ]

子路由<router-outlet></router-outlet>

  1. {path:'home',component:HomeComponent,
  2. children:[
  3. {path:'',component:XxxComponent},
  4. {path:'/yyy', component:YyyComponent}
  5. ]
  6. }

辅助路由

  1. <router-outlet></router-outlet>
  2. <router-outlet name="aux"></router-outlet>
  1. {path: 'xxx',component:XxxComponent,outlet:'aux'}
  2. {path: 'yyy',component:YyyComponent,outlet:'aux'}
  1. <a [routerLink]="['/home',{outlets:{aux:'xxx'}}]">Xxx</a>
  2. <a [routerLink]="['/product',{outlets:{aux:'yyy'}}]">Yyy</a>

路由守卫

  1. CanActivate:处理导航到某路由的情况
  2. CanDeactivate:处理从当前路由离开的情况
  3. Resolve:在路由激活之前获取路由数据

angular 路由的更多相关文章

  1. angular路由——ui.route

    angular路由 使用案例 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  2. angular路由详解:

    1.$routeProvider ngRoute模块中的服务 2.otherwise:设置用于路由改变时,与任何其他定义的路由无法匹配的时候执行的代码 3.when:为$route服务定义新的路由 例 ...

  3. angular 路由的引用

    使用angular路由 遇到的坑. 使用cmd 安装好node.js 安装成功 输入node  -v 能查看版本说明安装成功 搭建angular项目输入命令 npm install  -g  angu ...

  4. angular 路由项目例子

    angular 路由是我在工作中体验非常便捷的一点, 这是详细的API ,查看API 可以了解很多东西, https://github.com/angular-ui/ui-router/wiki/Qu ...

  5. Angular路由参数传递

    一.路由时传递参数的方式 1.在查询参数中传递数据 //页面 <a routerLink="/product" [queryParams]="{id:1}" ...

  6. angular路由(自带路由篇)

    一.angular路由是什么? 为了实现SPA多视图的切换的效果,其原理可简述为每个 URL 都有对应的视图和控制器.所以当我们给url后面拼上不同的参数就能通过路由实现不同视图的切换. 二.文件总览 ...

  7. Angular路由守卫 canActivate

    作用 canActivate 控制是否允许进入路由. canActivateChild 等同 canActivate,只不过针对是所有子路由. 关键代码 创建路由守卫 import { Injecta ...

  8. Angular路由守卫 canDeactivate

    目的 离开页面时,做出逻辑判断 以ng-alain的项目为基础做演示 效果如图: 关键代码 定义一个CanDeactivateGuardService export class CanDeactiva ...

  9. Angular 路由守卫

    1. 路由 Angular路由: 可以控制页面跳转:可以在多视图间切换: 2. 路由守卫 Angular路由守卫: 在进入或离开某路由时,用于判断是否可以离开.进入某路由::: return true ...

  10. angularjs中使用锚点,angular路由导致锚点失效的两种解决方案

     壹 ❀ 引 公司新项目开发中,首页要做个楼层导航效果(如下图),要求能点击图标对应跳到楼层即可,因为不需要跳转过度动画,也要求最好别用JQ,想着原生js操作dom计算top的兼容性,想着用锚点实现算 ...

随机推荐

  1. HttpOperater

    using System; using System.IO; using System.Linq; using System.Net; using System.Text; using System. ...

  2. Webkit初始化以及载入URL过程中各种对象的建立时序以及DOM树的建立详情分析

            众所周知,Webkit须要创建DOM树. 为此它须要创建WebView, Chrome,Page,Frame, Document. Document Parser, DOM Tree ...

  3. Graphics View框架

    Qt4.2开始引入了Graphics View框架用来取代Qt3中的Canvas模块,并在很多地方作了改进,Graphics View框架实现了模型-视图结构的图形管理,能对大量图元进行管理,支持碰撞 ...

  4. linux 终端 查看上一页

    问题描述: 我在终端中使用”dpkg -l”命令显示主机中安装的软件时,发现内容很多,而当命令执行完毕后,只显示终端最后一屏的内容.前面的都无法查看,这个是很让人憋屈的.下面就这一个问题说一下我的解决 ...

  5. Xcode常见问题

    今天真机测试的时候,突然出现了这个错误:  not have an architecture that “Administrator”的 iPhone (3) can execute. 原因是我刚刚修 ...

  6. nginx+keeplived负载均衡配置

    一.nginx 编译安装 1.依赖环境安装     yum -y install gcc gcc-c++ zlib zlib-devel pcre pcre-devel openssl openssl ...

  7. 关于锚点(anchorPoint)的一些理解

    默认来说,锚点位于图层的中点.对锚点一直不太了解是怎么移动的,有时候搞明白过不久碰到了又是懵逼,这次专门记录下来自己的一些理解,有不对的也请指教一下.就用下张图来简单的说明,每个视图的左上角锚点位置为 ...

  8. golang Time to String

    golang Time to String allenhaozi · 2016-09-02 09:00:00 · 2447 次点击 · 预计阅读时间 1 分钟 · 19分钟之前 开始浏览 这是一个创建 ...

  9. C语言错误: CRT detected that the application wrote to memory after end of heap buffer

    CRT detected that the application wrote to memory after end of heap buffer 多是中间对其进行了一些操作,在程序结束处,释放内存 ...

  10. Tagger: Deep Unsupervised Perceptual Grouping

    没看论文,但看了介绍视频,简直做了一个小型纪录片. 视频地址:https://www.youtube.com/watch?v=jfB_lWZA4Qo 中文翻译:http://blog.csdn.net ...