这是我目前使用旧库的尝试.
我现在正在使用最新的库,我将如何更新:
import { Component,} from '@angular/core'; import { Location } from '@angular/common'; import { Router } from '@angular/router'; @Component({ moduleId: module.id,selector: 'HeaderComponent',templateUrl: 'header.component.html' }) export class HeaderComponent{ router : Router; constructor(router: Router,location: Location){ this.router = router; this.router.changes.subscribe((currentRoute) => { let currentRoute = this.location.path(); }) } }
这是我的模块:
export * from './header.component'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; import { HeaderComponent } from './header.component'; @NgModule({ imports: [RouterModule,CommonModule],declarations: [HeaderComponent],exports: [HeaderComponent],providers: [] }) export class HeaderModule { }
解决方法
在新的路由器中
this.router.events.subscribe(...)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。