Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

ModelFunction

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.

See more...

      
      interface ModelFunction {
  required: {...}
<T>(): ModelSignal<T | undefined>
<T>(initialValue: T, opts?: ModelOptions): ModelSignal<T> }

Description

The function exposes an API for also declaring required models via the model.required function.

Properties

Property Description
required: { <T>(opts?: ModelOptions): ModelSignal<T>; }

Methods

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

      
      <T>(): ModelSignal<T | undefined>
    
Parameters

There are no parameters.

Returns

ModelSignal<T | undefined>

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

      
      <T>(initialValue: T, opts?: ModelOptions): ModelSignal<T>
    
Parameters
initialValue T
opts ModelOptions

Optional. Default is undefined.

Returns

ModelSignal<T>