我有以下文件:
.html
<nav>
<md-toolbar color = "primary">
<a [routerLink] = "['new-patient']">New Patient</a>
<button md-icon-button
color = "accent">
<md-icon class = "material-icons md-24">person_add</md-icon>
</button>
</md-toolbar>
</nav>
.ts
import { Component, OnInit } from '@angular/core';
import { ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router';
import { MdToolbar } from '@angular2-material/toolbar';
import { MdIcon, MdIconRegistry } from '@angular2-material/icon';
import { MdButton } from '@angular2-material/button';
@Component({
moduleId: module.id,
selector: 'epimss-toolbar',
templateUrl: 'toolbar.component.html',
styleUrls: ['toolbar.component.css'],
providers: [MdIconRegistry],
directives: [MdButton, MdIcon, MdToolbar, ROUTER_DIRECTIVES],
})
export class ToolbarComponent implements OnInit {
constructor() {}
ngOnInit() {
}
}
我的路由器实际上可以使用上面的代码。
但是,我正在尝试<a [routerLink] = "['new-patient']">New Patient</a>
成为一个路由,当
<button md-icon-button
color = "accent">
<md-icon class = "material-icons md-24">person_add</md-icon>
</button>
被点击。
我尝试了以下方法,但它不起作用。
<button md-icon-button
color = "accent"
[routerLink] = "['new-patient']">
<md-icon class = "material-icons md-24">person_add</md-icon>
</button>
感谢您提供的任何帮助,谢谢。