Angular Tutorial 0/55 lessons ~6 min read Lesson 41

    Angular model() Two-Way Inputs

    Angular model() Two-Way Inputs in Advanced Angular: core concepts, worked examples, and practical guidance in one focused lesson.

    Course progress0%
    Focus
    5 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    model() creates a two-way bindable signal input — the modern replacement for many [(ngModel)]-style component APIs without requiring FormsModule on the child.

    Purpose of this lesson

    You will build a child that supports banana-in-a-box binding via model().

    Understanding the topic

    Mental model:

    • value = model(0) — writable from inside; bindable as [(value)] from outside.
    • model.required<T>() when the parent must supply a binding.
    • Updating value.set(x) notifies the parent binding.
    • Still use Reactive Forms for complex form graphs; model() shines for reusable controls and UI state.

    Informative example

    Counter with two-way binding:

    typescript
    import { Component, model } from "@angular/core";
    @Component({
    selector: "tlp-counter",
    template: `
    <button type="button" (click)="dec()">-</button>
    <span>{{ count() }}</span>
    <button type="button" (click)="inc()">+</button>
    `,
    })
    export class CounterComponent {
    count = model(0);
    inc() { this.count.update((n) => n + 1); }
    dec() { this.count.update((n) => n - 1); }
    }
    // Parent:
    // <tlp-counter [(count)]="seats" />

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    1 questions
    1BeginnerQuestionHow is model() different from input()?+

    Answer

    input() is read-only from the child. model() is a writable signal that also participates in two-way binding with the parent via [(name)].
    Ready to mark this lesson complete?Track your journey across the entire course.