• Overview
@angular/core

model

Initializer API

model declares a writeable signal that is exposed as an input/output pair on the containing directive.

The input name is taken either from the class member or from the alias option. The output name is generated by taking the input name and appending Change.

  
    
  
  
function model<T>(): ModelSignal<T | undefined>;

Initializes a model of type T with an initial value of undefined. Angular will implicitly use undefined as initial value.

@returnsModelSignal<T | undefined>
function model<T>(initialValue: T, opts?: ModelOptions | undefined): ModelSignal<T>;

Initializes a model of type T with the given initial value.

@paraminitialValueT
@paramoptsModelOptions | undefined
@returnsModelSignal<T>
function model.required<T>(opts?: ModelOptions | undefined): ModelSignal<T>;

Initializes a required model.

Users of your directive/component need to bind to the input side of the model. If unset, a compile time error will be reported.

@paramoptsModelOptions | undefined
@returnsModelSignal<T>
Jump to details