시작시 AppComponent에서 다른 경로를 탐색하려고하는데 작동하지 않는 것 같습니다. 내 app.component, 나는 내 ngOnInit 방법을 탐색하려고 : 내 main.ts에서각도 2 - 부트 스트랩을 탐색하는 방법?
export class AppComponent implements OnInit {
constructor(private _router: Router) {
}
ngOnInit() {
console.log("IN ngOnInit!!!!!!!!!!!!!!!!!!!!");
this._router.navigate(["/login"]).then(() => console.log("DONE Navigation!!!!!!!!!!!!!!!!!!!!")).catch(err => console.log("Error!!!!!: " + err));
console.log("GOING OUT ngOnInit!!!!!!!!!!!!!!!!!!!!");
}
}
, 내가 구성 요소 부트 스트랩 :
bootstrap(AppComponent, [
APP_ROUTER_PROVIDERS
]).then(() => console.log("DONE BOOTSTRAP"));
그리고 콘솔 출력은 다음과 같습니다
IN ngOnInit!!!!!!!!!!!!!!!!!!!!
GOING OUT ngOnInit!!!!!!!!!!!!!!!!!!!!
DONE Navigation!!!!!!!!!!!!!!!!!!!!
DONE BOOTSTRAP
내 생각 엔 부트 스트랩이 APP_ROUTER_PROVIDERS에 대해 완료되지 않았기 때문에 내비게이션을 수행 할 수 없다고 생각합니다. 부트 스트랩이 완료된 후에 탐색 할 수 있도록 연결할 수있는 이벤트가 있습니까? 저는 Angular 2 RC4에 있습니다.
미리 감사드립니다.
정보를 제공해 주셔서 감사합니다! –
나는 네비게이션 경로를 결정하기 위해 약간의 로직을 수행 할 필요가 있기 때문에 이것을 대답으로 선택했다. –