Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 使用了observable返回
- ngOnInit() {
- this.hero$ = this.route.paramMap
- .switchMap((params: ParamMap) =>
- this.service.getHero(params.get('id')));
- }
- // 使用了快照,直接返回
- ngOnInit() {
- let id = this.route.snapshot.paramMap.get('id');
- this.hero$ = this.service.getHero(id);
- }
Add Comment
Please, Sign In to add comment