Guest User

Untitled

a guest
Mar 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. // 使用了observable返回
  2. ngOnInit() {
  3. this.hero$ = this.route.paramMap
  4. .switchMap((params: ParamMap) =>
  5. this.service.getHero(params.get('id')));
  6. }
  7.  
  8. // 使用了快照,直接返回
  9. ngOnInit() {
  10. let id = this.route.snapshot.paramMap.get('id');
  11. this.hero$ = this.service.getHero(id);
  12. }
Add Comment
Please, Sign In to add comment