组件"AppComponent"没有路由配置,未定义路由器进行导航 [英] Component "AppComponent" has no route config, router is undefined to navigate
本文介绍了组件"AppComponent"没有路由配置,未定义路由器进行导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import { Component } from 'angular2/core';
import { Router } from 'angular2/router';
import { RouteConfig } from 'angular2/router';
import { ROUTER_DIRECTIVES } from 'angular2/router';
import { LandingComponent } from './landing.component';
@RouteConfig([
{path: '/landing', name: 'Landing', component: LandingComponent},
{path: '/*other', name: 'Other', redirectTo: ['Landing']}
]);
@Component({
selector: 'cwf',
templateUrl: 'app/template/index.template.html',
directives: [ROUTER_DIRECTIVES]
})
export class AppComponent {
constructor(private _router:Router){
}
browserObject = BrowserDetect;
navigator = navigator.javaEnabled() ? "enabled" : "disabled";
listBrowser = BrowserDetect.supportedBrowser;
ngOnInit(){
let timer = Observable.timer(2000);
timer.subscribe(this.navigate);
};
navigate = () => {
this._router.navigate(['Landing']);
};
}
推荐答案
删除
@RouteConfig([
{path: '/landing', name: 'Landing', component: LandingComponent},
{path: '/*other', name: 'Other', redirectTo: ['Landing']}
]);
这篇关于组件"AppComponent"没有路由配置,未定义路由器进行导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文