Ren*_*ima 5 routing ng-class angular
我想在某条路线上添加课程.代码在我的AppComponent中,我使用的是ngClass.
    @Component({
     selector: 'my-app',
     template: `<a [ngClass]="getRoute(router)">
       // Some html code....
    })
然后我在相同的app.component.ts上有这个功能
  export class AppComponent  { 
    getRoute(){
     if (this.router.url === '/atendimento'){
      return "hide-bar";
   }
  }
 }
我得到的错误如下:
'AppComponent'类型中不存在属性'router'
是的,我在标题上导入Routes,RouterModule和Router.有人能帮我吗?
提前致谢
需要注入路由器
  export class AppComponent  { 
    constructor(private router:Router) {}
    getRoute(){
     if (this.router.url === '/atendimento'){
| 归档时间: | 
 | 
| 查看次数: | 3415 次 | 
| 最近记录: |