Q. What does the 'async' pipe do when the observable emits a new value?

  • (A) It unsubscribes automatically
  • (B) It logs the value
  • (C) It updates the view automatically
  • (D) It refreshes the page
πŸ’¬ Discuss
βœ… Correct Answer: (C) It updates the view automatically
Explanation: The async pipe updates the DOM when a new value is emitted.

Q. How do you navigate to another route in Angular programmatically?

  • (A) location.href = '/route'
  • (B) this.route.go('/route')
  • (C) this.router.navigate(['/route'])
  • (D) window.location.replace('/route')
πŸ’¬ Discuss
βœ… Correct Answer: (C) this.router.navigate(['/route'])
Explanation: Use the Router service’s `navigate` method to change routes programmatically.

Q. What is a feature module in Angular?

  • (A) A module that handles authentication only
  • (B) A module created using CLI
  • (C) A module that focuses on a specific feature
  • (D) The root module of the app
πŸ’¬ Discuss
βœ… Correct Answer: (C) A module that focuses on a specific feature
Explanation: Feature modules group code related to a particular feature.

Q. What is the key advantage of lazy loading in Angular?

  • (A) Reduces API load
  • (B) Improves security
  • (C) Reduces initial load time
  • (D) Improves build size
πŸ’¬ Discuss
βœ… Correct Answer: (C) Reduces initial load time
Explanation: Lazy loading loads modules only when needed, reducing initial bundle size.

Q. How do you protect a route from unauthorized access?

  • (A) Use ngIf in the template
  • (B) Use ngStyle
  • (C) Use CanActivate guard
  • (D) Use ngSwitch
πŸ’¬ Discuss
βœ… Correct Answer: (C) Use CanActivate guard
Explanation: CanActivate guard determines if a route can be activated based on conditions.

Q. What is the purpose of NgZone in Angular?

  • (A) To create zones for routing
  • (B) To manage service injection
  • (C) To run code outside Angular’s zone and improve performance
  • (D) To render templates faster
πŸ’¬ Discuss
βœ… Correct Answer: (C) To run code outside Angular’s zone and improve performance
Explanation: NgZone lets you run code outside Angular's change detection for performance gains.

Q. Which Angular directive conditionally includes or removes an element in the DOM?

  • (A) *ngFor
  • (B) *ngSwitch
  • (C) *ngIf
  • (D) ngStyle
πŸ’¬ Discuss
βœ… Correct Answer: (C) *ngIf
Explanation: *ngIf adds or removes elements based on a condition.

Q. What is the role of the RouterModule.forRoot() method?

  • (A) To create a new module
  • (B) To define routes at the root level
  • (C) To provide form support
  • (D) To register a service globally
πŸ’¬ Discuss
βœ… Correct Answer: (B) To define routes at the root level
Explanation: RouterModule.forRoot() sets up routing for the root app module.

Q. Which Angular concept makes the app reactive and supports stateful behaviors?

  • (A) Template Binding
  • (B) Zone.js
  • (C) RxJS Observables
  • (D) NgModel
πŸ’¬ Discuss
βœ… Correct Answer: (C) RxJS Observables
Explanation: Angular’s reactivity is powered by RxJS Observables.

Q. What is the purpose of the 'ng-template' element in Angular?

  • (A) To create standalone components
  • (B) To hold reusable HTML code
  • (C) To mark content for dynamic rendering
  • (D) To style child components
πŸ’¬ Discuss
βœ… Correct Answer: (C) To mark content for dynamic rendering
Explanation: ng-template holds content that will be rendered conditionally or dynamically.