Forms Advanced — Angular Technical Interview Questions & Answers

Forms Advanced

Forms Advanced

  • Advanced forms: FormArray for a list of subjects, cross-field validator (password === confirm), valueChanges to enable a button, async validator that checks roll on the server.
  • Board: subjects FormArray. Add subject row. Remove row. Trap: validators on the group but not updating when one child changes — include { updateOn: 'blur' } only if you mean it.

Technical Interview Tip: FormArray + one cross-field validator.

Code Examples for Forms Advanced

Forms Advanced — working example

import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  template: `
    <h1>{{ title }}</h1>
    <button (click)="toggle()">Toggle</button>
    <p *ngIf="open">Panel open</p>
  `,
})
export class AppComponent {
  title = "Angular practice";
  open = true;
  toggle() {
    this.open = !this.open;
  }
}

Forms Advanced: toggle open. Say whether the panel is on screen after one click.

How to Explain Forms Advanced to an Interviewer

When do you need FormArray?

Repeating fields Add/remove subject rows