0

I saw in the Angular tour of heroes tutorial, they declare hero$!: Observable<Hero>;

Why is there ! sign after the $ ?

They are also initializing the hero observable in the ngOnInit

ngOnInit() {
    this.hero$ = this.route.paramMap.pipe(
      switchMap((params: ParamMap) =>
        this.service.getHero(params.get('id')!))
    );
  }

And there, we also see the ! sign on params.get('id')!

Ainaraza
  • 62
  • 3
  • 4
    https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#definite-assignment-assertions – Jayce444 May 19 '21 at 06:10
  • @Jayce444, thank you, this answers my question, I was not sure if it was a Angular or Typescript feature – Ainaraza May 19 '21 at 06:14

0 Answers0