[Angular2 Router] Guard: CanLoad
'canLoad' guard can decide whether a lazy load module can be loaded or not.
@Injectable()
export class CanLoadPokemon implements CanLoad { constructor(private authService: AuthService) { }
canLoad(route: Route): Observable<boolean>|Promise<boolean>|boolean {
return this.authService.isAuth;
} }
app.routers.ts:
{path: 'home', loadChildren: 'app/home/home.module', data: {title: 'Pokemon List'}, canLoad: [CanLoadPokemon]},
So if user not login, app won't load home module.
[Angular2 Router] Guard: CanLoad的更多相关文章
- [Angular2 Router] Resolving route data in Angular 2
From Article: RESOLVING ROUTE DATA IN ANGULAR 2 Github If you know Anuglar UI router, you must know ...
- [Angular2 Router] CanActivate Route Guard - An Example of An Asynchronous Route Guard
In this tutorial we are going to learn how we can to configure an can activate route guard in the An ...
- [Angular2 Router] CanDeactivate Route Guard - How To Confirm If The User Wants To Exit A Route
In this tutorial we are going to learn how we can to configure an exit guard in the Angular 2 Router ...
- Angular2 Router路由相关
路由设置 Angular中路由的配置应该按照先具体路由到通用路由的设置,因为Angular使用先匹配者优先的原则. 示例: 路由设置如下: export const reportRoute: Rout ...
- [Angular2 Router] Exiting an Angular 2 Route - How To Prevent Memory Leaks
In this tutorial we are going to learn how we can accidentally creating memory leaks in our applicat ...
- [Angular2 Router] Optional Route Query Parameters - The queryParams Directive and the Query Parameters Observable
In this tutorial we are going to learn how to use the Angular 2 router to pass optional query parame ...
- [Angular2 Router] Using snapshot in Router
In the application, we have heros list, when click each hero, will redirect to hero detail view. Tha ...
- [Angular2 Router] Programmatic Router Navigation via the Router API - Relative And Absolute Router Navigation
In this tutorial we are going to learn how to navigate programmatically (or imperatively) by using t ...
- [Angular2 Router] Configuring a Home Route and Fallback Route - Learn An Essential Routing Concept
In this tutorial we are going to learn how to configure the Angular 2 router to cover some commonly ...
随机推荐
- _00018 Hadoop-2.2.0 + Hbase-0.96.2 + Hive-0.13.1 分布式环境整合,Hadoop-2.X使用HA方式
博文作者:妳那伊抹微笑 itdog8 地址链接 : http://www.itdog8.com(个人链接) 博客地址:http://blog.csdn.net/u012185296 个性签名:世界上最 ...
- absolute、relative,toggle()
測试代码例如以下: <div> <div class="global">不应用样式</div> <div class="glob ...
- Codeforces Round #316 (Div. 2) A B C
A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- LINUX下为apache 和 PHP 添加模块
LINUX下为apache 和 PHP 添加模块https://www.path8.net/tn/archives/4717/opt/lampp/bin/httpd -V/opt/lampp/bin/ ...
- xampp 在 centos 中无法启动的解决办法
修改这个文件 vim /opt/lampp/lampp 找到 if egrep "9 " /etc/redhat-release > /dev/null更改为 if ...
- 关于大数据项目创建时所需setting.xml(博主推荐)
我目前,收录经常用的是,这两个版本,这个根据博主我本人的经验之谈,最为稳定和合理的. 注意:我的本地路径是在D:/SoftWare/maven/repository,大家自己改为你们自己的即可. ...
- Linux库文件路径的添加
库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程序)时被使用,其搜索路径是在系统中进行设置的.一般 Linux 系统把 /lib 和 /usr/lib 两个目录作为默认的库搜索路径,所以使用 ...
- 关于img标签的探讨
关于img标签的探讨:一直以来img属于那一种标签受到困惑,因为它既有块元素的特性也有行内元素的属性.它独占一行,也可以设置宽高. 在此重新学习一下标签元素的分类;html元素的分类:块元素.内联元素 ...
- mysql中load data Infile运用
速度比insert要快20倍.共享一下java程序操作. package com.mysql.csv; import java.sql.Connection; import java.sql.Driv ...
- android.mk-编译文件学习(转载)
工作了那么久,都是使用大神们写的脚本机械的编译,对于android.mk根本没去了解过.今天趁着这个机会,在网上搜索了下.虽然依然不是很名白,留做记录,以后真用到了,再深入研究 转载自 http:// ...