0Pricing
Angular Academy · Lesson

Custom Two-Way Bindable Properties

Expose your own two-way bindable inputs.

Custom Two-Way Bindable Properties is a free Angular Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Custom Two-Way Binding

You can make any component property two-way bindable. Angular supports two approaches: the classic @Input plus @Output pair, or the modern model() signal.

The Naming Convention

For two-way binding to work, the output name must be the input name plus the suffix Change. For example, input size needs output sizeChange.

Declaring the Input

Start with an ordinary input that the parent can set.

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

export class RatingComponent {
  @Input() value = 0;
}

Declaring the Matching Output

Add an @Output EventEmitter named with the Change suffix.

import { Input, Output, EventEmitter } from "@angular/core";

export class RatingComponent {
  @Input() value = 0;
  @Output() valueChange = new EventEmitter<number>();
}

Emitting on Update

When the component changes the value internally, update the property and emit the new value so the parent stays in sync.

setValue(v: number) {
  this.value = v;
  this.valueChange.emit(v);
}

Binding from the Parent

Now the parent can use the banana-in-a-box syntax against your custom property.

<app-rating [(value)]="score"></app-rating>

// parent
score = 3;

Full Input/Output Example

Here is a complete custom two-way bindable component using the classic API.

@Component({
  selector: "app-rating",
  template: "<button (click)='bump()'>{{ value }}</button>"
})
export class RatingComponent {
  @Input() value = 0;
  @Output() valueChange = new EventEmitter<number>();
  bump() {
    this.value++;
    this.valueChange.emit(this.value);
  }
}

The Modern model Approach

The same behavior is far shorter with model(), which creates the input and output pair for you.

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

@Component({
  selector: "app-rating",
  template: "<button (click)='bump()'>{{ value() }}</button>"
})
export class RatingComponent {
  value = model(0);
  bump() { this.value.update(v => v + 1); }
}

Comparing the Two Approaches

The classic pair is explicit and works everywhere; model() is concise and signal-based. Both expose the same [(value)] binding to parents.

Multiple Two-Way Properties

A component can expose several two-way bindable properties, each following the input/inputChange convention.

@Input() min = 0;
@Output() minChange = new EventEmitter<number>();
@Input() max = 100;
@Output() maxChange = new EventEmitter<number>();

Choosing an Approach

For new code, prefer model() for brevity and signal integration. Use the explicit input/output pair when you need fine control or are not using signals.

Quick Check

Test your understanding of custom two-way bindable properties.

Recap

Custom two-way binding needs an input plus an output named inputChange, emitting on every update. The modern model() signal creates that pair automatically and is the concise choice for new code.

Frequently asked questions

Is the “Custom Two-Way Bindable Properties” lesson free?

Yes — the full text of “Custom Two-Way Bindable Properties” is free to read here on the web, and the Angular Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Angular Academy course, upgrade to CoddyKit PRO.

What will I learn in “Custom Two-Way Bindable Properties”?

Expose your own two-way bindable inputs. You practise Angular Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Angular Academy?

No prior experience is required. Angular Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Custom Two-Way Bindable Properties” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Angular Academy lesson?

Yes. Every Angular Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Property and Event Binding Recap
  2. Two-Way Binding with ngModel
  3. model() Signal Inputs
  4. Custom Two-Way Bindable Properties
← Back to Angular Academy