Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which is the cleanest way to consume an observable in a template?

  1. A Subscribing in ngOnInit and assigning to a field
  2. B Using the async pipe
  3. C Using toPromise()
  4. D Calling subscribe in the template
Answer

Using the async pipe

The async pipe subscribes and unsubscribes automatically and works correctly with OnPush change detection.

All Angular MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as