[Angular2 Router] Style the Active Angular 2 Navigation Element with routerLinkActive
You can easily show the user which route they are on using Angular 2’s routerLinkActive. Whenever a route matches the routerLink defined on the element, then the routerLInkActive will add the class that you assign it to.
app.component.ts:
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}
app.component.css:
a{
text-decoration: none;
}
a.active{
font-weight: bold;
color: darkred;
}
app.component.html:
<nav>
<a [routerLink]="''"
routerLinkActive="active"
[routerLinkActiveOptions]="{exact: true}">Home</a>
<a
[routerLink]="'contact'"
routerLinkActive="active"
>Contact</a>
</nav>
<router-outlet></router-outlet>
[Angular2 Router] Style the Active Angular 2 Navigation Element with routerLinkActive的更多相关文章
- [Angular2 Router] Use Params from Angular 2 Routes Inside of Components
Angular 2’s ActivatedRoute allows you to get the details of the current route into your components. ...
- [Angular2 Form] Style Validation in Angular 2 Forms
Inputs using Angular 2’s ngModel automatically apply style classes of .ng-validand .ng-invalid each ...
- [Angular2 Router] Build Angular 2 Navigation with routerLink
Angular 2 navigation is configured using the routerLink directive. The routerLink directive behaves ...
- [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] Index router
Index router as default router. import {RouterModule} from "@angular/router"; import {NotF ...
- [Angular2 Router] Setup page title with Router events
Article import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator ...
- 解决TS报错Property 'style' does not exist on type 'Element'
在使用queryselector获取一个dom元素,编译时却报错说property 'style' does not exist on type 'element'. 原因:这是typescript的 ...
- 在Angular中使用element
在angular中使用element 1.在一个新建的angular的项目中插入element npm i --save element-angular 2.在项目中的styles.css中插入文件, ...
- [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 ...
随机推荐
- vim 7.4 编译安装
(1): 在安装新版本的Vim之前,你需要卸载原来安装的老版本Vim,依次在终端下执行下列命令: sudo apt-get remove vim sudo apt-get remove vim-run ...
- 通过xshell 设置代理上网
前言: 前段时间,选修了一门并行计算,老师给我们每个人分配了一个linux登录账号,通过这个账号,可能登录学校的一台linux . 一次偶然的机会,了解到可以通过xshell , ssh服务器给本地开 ...
- windows端口被占用
查看端口号被占用进程netstat -a -n -o 强制结束PIDtaskkill /pid:604 /F
- c++ struct 使用
typedef与结构结合使用 typedef struct tagMyStruct{ int iNum; long lLength;} MyStruct; 这语句实际上完成两个操作: 1) 定义一 ...
- deque 居然已经实现了 insert 接口
最近有个开发需求,根据server传递来的广告位来展示某条广告. 但最终存储广告的数据结构是deque,里面存储的东西还是对象(stl 基于拷贝语义). 想了半天,在开头和结尾插入比较方便,在中间插入 ...
- 研究QGIS二次开发笔记(一)
为了在QT程序中嵌入一个地图,最终选择了QGIS来干这件事.选型阶段真是呵呵.我折腾的是QGIS2.4.0. 首先,到官方网站下载安装QGIS.如果你跟我一样懒的话,可能希望下载一个已经编译好的win ...
- Python基础-函数(function)
这里我们看看Python中函数定义的语法,函数的局部变量,函数的参数,Python中函数的形参可以有默认值,参数的传递是赋值操作,在函数调用时,可以对实参进行打包和解包 1,函数定义 关键字def引 ...
- Client Dependency学习
Client Dependency Framework ---CDF CDF is a framework for managing CSS & JavaScript dependencies ...
- UVa11235 FrequentValues(RMQ)
Problem F: Frequent values You are given a sequence of n integers a1 , a2 , ... , an in non-decreasi ...
- HDU2897邂逅明下(博弈)
题目是说每次每个人可以取[p,q],而且是最后一个不得不取完的人输 这道题刚刚看别人过,还一直纠结感觉不会做,然后想到1+q的倍数,还是不会,想到p+q的倍数,却发现最后一个取的人是输的,然后就更加无 ...