Control Flow — Angular Technical Interview Questions & Answers

Control Flow

Control Flow

  • Control Flow is a Angular topic. In plain words you use it for a Pass banner in a marks card. Don’t start with a slogan — start with that picture.
  • Smallest example: *ngIf="marks >= 40". Type it, run it, and say what you see. If you can do that from memory, you know Control Flow.
  • From the example next to this theory: Control Flow: toggle open.
  • Trap: *ngIf treating 0 as false. Fix that before you talk about advanced Angular.
  • Viva: what is Control Flow? Then show *ngIf="marks >= 40". Then name the trap.

Technical Interview Tip: What is Control Flow? Show this: *ngIf="marks >= 40". Trap: *ngIf treating 0 as false.

Code Examples for Control Flow

Control Flow — 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;
  }
}

Control Flow: toggle open. Say whether the panel is on screen after one click.

How to Explain Control Flow to an Interviewer

What is Control Flow?

Used for a Pass banner a marks card Not just the heading

Give one small example of Control Flow.

*ngIf="marks >= 40" Control Flow: toggle open

What mistake do beginners make with Control Flow?

*ngIf treating 0 as false Show the fix

Where do you use Control Flow?

a marks card a Pass banner