1
NVM 0.31.0 : login.component.ts에서각도 2 라우팅 - 라우팅 매개 변수를 얻을 - 타이프 라이터
gotoProfile(id:number):void {
let link = ['/profile'];
console.log("Routing to /profile/"+id);
this.router.navigate(link, id);
}
콘솔을 Node.js를 6.6.0
: NPM 3.10.3을
C에서 profile.component.tsimport { Router, ActivatedRoute, Params } from '@angular/router';
constructor(private route:ActivatedRoute,
private router:Router,
private profileService:ProfileService) {
}
ngOnInit():void {
this.route.params
.subscribe(params => {
let id = params['id'];
console.log("id " + id);
this.profileService.getProfileById(id)
.subscribe(
p => this.model = p,
err => this.handleError(err),
() => console.log("getting profile complete")
);
});
에서
Routing to /profile/1
onsole :
app.routing.ts에서id undefined
path: 'profile/:id',
component: ProfileComponent
내가 다음 브라우저에서 입력하면 : http://localhost:3000/profile/1 콘솔 :
id 1
그래서 내가 여기에 무엇을 잃었 :)
이 예제에서는 Observable을 사용하고있는 Promise를 사용하고 있습니다. 나는 새로운 각도이고 나는 영웅 튜토리얼을 통과했다. – klind