我使用的是路由器3.0.0-alpha.8的Angular 2.0.0-rc3。角路由器3 routerLink不工作
我有一个BookListComponent
与下面的模板:
<nav>
<a routerLink="/new-book">New Book</a>
</nav>
<ul>
<li *ngFor="let book of books">{{ book.name }}</li>
</ul>
然后这里是BookListComponent
本身:
import { Component, OnInit } from '@angular/core';
import { BookService } from '../book.service';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
moduleId: module.id,
selector: 'app-book-list',
templateUrl: 'book-list.component.html',
styleUrls: ['book-list.component.css'],
providers: [ROUTER_DIRECTIVES, BookService]
})
export class BookListComponent implements OnInit {
books: any;
constructor(private bookService: BookService) {}
ngOnInit() {
this.bookService.getList()
.subscribe(response => this.books = response.json());
}
}
不仅链接不带我去/new-book
航线(其中,如果访问“手动”,工作得很好),但“链接”甚至不是一个链接 - 它只是黑色文本。
如何获得链接工作?
''New Book可能是值得一试。我已经看到一个关于routerLink的错误报告和一个字符串参数。无论如何更新路由器beta.2。 –