Angular interview questions

16 questions from the Angular Fundamentals: Components, Signals and Routing course, each with the correct answer and an explanation. Try to answer before you open the answer.

Module 2: Components

1. What replaces NgModule registration for a standalone component's dependencies?

  1. The `providers` array
  2. A separate `@NgModule` file
  3. The `imports` array
  4. The declarations array
Show answer

Answer: The `imports` array

Standalone components list what they need directly in `imports`.

Lesson: Standalone Components

Module 4: Control Flow in Templates

2. What does `@for` require that `*ngFor` did not strictly enforce?

  1. An `@empty` block
  2. An array wrapped in a Signal
  3. A pipe
  4. A `track` expression
Show answer

Answer: A `track` expression

`track` is mandatory in `@for` and helps Angular identify items efficiently across re-renders.

Lesson: @if, @for & @switch

Module 5: Component Communication

3. Which function guarantees a parent must always pass a value?

  1. input.required()
  2. input()
  3. output()
  4. output.required()
Show answer

Answer: input.required()

`input.required()` makes the compiler enforce that the parent always binds a value.

Lesson: @Input() & @Output()

Module 7: Routing

4. What is the main benefit of `loadComponent` over a plain `component` route?

  1. It skips route parameters
  2. It splits the component into a separate chunk loaded on demand
  3. It disables the router outlet
  4. It removes the router
Show answer

Answer: It splits the component into a separate chunk loaded on demand

The component code is only downloaded once the user actually navigates to that route.

Lesson: Lazy Loading

Module 8: Forms

5. Where do you attach validators to a reactive form control?

  1. As an attribute in the HTML template
  2. Inside the component's constructor only
  3. As the second argument when creating the FormControl
  4. In the CSS file
Show answer

Answer: As the second argument when creating the FormControl

`new FormControl('', [Validators.required])` passes validators directly to the control.

Lesson: Form Validation

Module 10: Lifecycle Hooks

6. Where should you clear a timer or unsubscribe from a stream?

  1. ngOnInit
  2. ngOnChanges
  3. ngAfterViewInit
  4. ngOnDestroy
Show answer

Answer: ngOnDestroy

ngOnDestroy runs right before the component is removed — the correct place for cleanup.

Lesson: ngOnInit, ngOnDestroy & ngOnChanges

Module 12: Signals

7. How do you read the current value of a signal named `count`?

  1. count()
  2. count.value
  3. count.get()
  4. count.read()
Show answer

Answer: count()

Signals are callable — `count()` reads the current value and registers a dependency.

Lesson: What are Signals?

Module 15: Testing & Deployment

8. What command packages an Angular app for deployment?

  1. ng serve
  2. ng build
  3. ng test
  4. ng generate
Show answer

Answer: ng build

`ng build` produces optimized static files in `dist/`, while `ng serve` is only for local development.

Lesson: Building for Production

9. What does a standalone component use to declare dependencies?

  1. An NgModule
  2. The providers array only
  3. The imports array
  4. A global script
Show answer

Answer: The imports array

Standalone components import what they use directly.

Lesson: Building for Production

10. Which syntax binds a DOM property to a value?

  1. (event)="fn()"
  2. {{ }} only
  3. #ref
  4. [property]="value"
Show answer

Answer: [property]="value"

Square brackets bind component data to the DOM.

Lesson: Building for Production

11. What must @for include?

  1. A track expression
  2. An @empty block
  3. A pipe
  4. A service
Show answer

Answer: A track expression

track lets Angular update the DOM efficiently.

Lesson: Building for Production

12. How do you read a signal named count?

  1. count.value
  2. count()
  3. count.get()
  4. count[0]
Show answer

Answer: count()

Signals are read by calling them like functions.

Lesson: Building for Production

13. Where should you unsubscribe or clear timers?

  1. ngOnInit
  2. constructor only
  3. ngOnDestroy
  4. ngOnChanges
Show answer

Answer: ngOnDestroy

ngOnDestroy runs when the component is removed.

Lesson: Building for Production

14. What is the benefit of lazy loading routes?

  1. Faster typing
  2. More modules
  3. No router
  4. A smaller initial bundle
Show answer

Answer: A smaller initial bundle

Components load only when visited.

Lesson: Building for Production

15. Which form approach builds the model in TypeScript?

  1. Reactive forms
  2. Template-driven forms
  3. Inline styles
  4. Pipes
Show answer

Answer: Reactive forms

FormGroup and FormControl define the model explicitly.

Lesson: Building for Production

16. What does hydration avoid after server-side rendering?

  1. Sending HTML
  2. Rebuilding the DOM from scratch
  3. Using HTTP
  4. Routing
Show answer

Answer: Rebuilding the DOM from scratch

Hydration reuses server-rendered DOM and attaches listeners.

Lesson: Building for Production

← Back to the course