0
active2をactive2に割り当てたいのですが、Angular2はliタグにアクティブクラスを割り当てます
これは私が私のTSに
<li [class.active]=" _router.isRouteActive(_router.generate(['/dashboard']))" >
//the above _router.isRouteActive throws an error
<a routerLink="/dashboard">
<i class="icon-display4 position-left"></i> Dashboard</a>
</li>
を試してきたものであるが、ファイルIは
export class SecondaryNavComponent implements OnInit {
//thinking of using to determine active link
constructor(public _router:Router) { } //tried also with private
ngOnInit() {
}
}
エラーが間違っている可能性が何
ERROR TypeError: co._router.generate is not a function
ALse webstorm generates an error that
unkwon method router is active
を読み取っていますか?
routerLinkアクティブディレクティブは、タグにアクティブなクラスを設定しますが、外側にはありません –
また、routerLinkの祖先にアクティブクラスを設定して、クラス説明セクションを例で読むことができます – cyrix
with ..............最後に、RouterLinkActiveディレクティブをRouterLinkの祖先に適用することができます。 –