2016-07-19 37 views
1
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']); 
    };  

} 
+0

末尾刪除;。 我已經包括在HTML 我已包括從 'angular2 /路由器' 自舉(AppComponent,[ROUTER_PROVIDERS]){進口ROUTER_PROVIDERS};在boot.ts 仍然我得到這種錯誤..請告訴我什麼是問題。 –

+1

您可以編輯您的問題並在其中添加其他信息。 –

回答

2

在我想對瀏覽超時頁面

@RouteConfig([  
    {path: '/landing', name: 'Landing', component: LandingComponent}, 
    {path: '/*other', name: 'Other', redirectTo: ['Landing']}  
]); 
+0

如果這解決了您的問題,請您接受答案(上/下按鈕下方的白色複選標記),以表明此問題已得到解答。謝謝。 –

+0

我有像這樣的着陸頁...從'angular2/core'導入{Component}; @Component({ \t選擇: '登陸', \t templateUrl: '應用程序/模板/ landing.template.html' }); 出口類LandingComponent { \t } //我正在上LandingComponent找不到指令註解..你能告訴我原因 –

+0

你再有';'在@Component的'結束(...) ;/* <<< === */export class LandingComponent {}'。裝飾者和他們正在裝飾的課堂之間不能有「;」 –