Angular 2路由onActivate [英] Angular 2 routing onActivate

查看:177
本文介绍了Angular 2路由onActivate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个组件以使用routerOnActivate钩子,但是遇到一个错误组件...中缺少属性routerOnActivate....",并且组件名称'SettingsHomeComponent'用红色下划线显示.这也是一条儿童路线...

I'm trying to setup a component to use the routerOnActivate hook, but am getting an error "that property routerOnActivate is missing in component....' and the Component name 'SettingsHomeComponent' is underlined in red. This is also a child route...

import {Component} from '@angular/core';
import {Routes, RouteSegment, RouteTree, ROUTER_DIRECTIVES, OnActivate} from '@angular/router';
import {SettingsProfileComponent} from '../profile/settings.profile.component';

@Component({
    selector: 'kg-Settings ',
    templateUrl: './app/components/settings/home/settings.home.component.html',
    directives: [ROUTER_DIRECTIVES]
})

export class SettingsHomeComponent implements OnActivate{
 public isSettingsHome: boolean = false;
  
  routerOnAcivate(curr: RouteSegment, prev?: RouteSegment, currTree?: RouteTree, prevTree?: RouteTree) :void {
       
   }
}

任何人都可以看到错误或告诉我这里出了什么问题吗...

Can anyone see the error or tell me what is wrong here...

谢谢.

推荐答案

错字

routerOnAcivate

应该是

routerOnActivate

(缺少t)

这篇关于Angular 2路由onActivate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆