@@ -31,72 +31,74 @@ export function modelRequiredFunction<T>(): ModelSignal<T> {
3131 * The function exposes an API for also declaring required models via the
3232 * `model.required` function.
3333 *
34- * @usageNotes
35- * Initialize a model in your directive or component by declaring a
36- * class field and initializing it with the `model()` or `model.required()`
37- * function.
38- *
39- * ```ts
40- * @Directive ({..})
41- * export class MyDir {
42- * firstName = model<string>(); // string|undefined
43- * lastName = model.required<string>(); // string
44- * age = model(0); // number
45- * }
46- * ```
47- *
4834 * @developerPreview
4935 */
5036export interface ModelFunction {
5137 /**
52- * Initializes a model with an initial value. If no explicit value
53- * is specified, Angular will use `undefined`.
54- *
55- * Consider using `model.required` for models that don't need an
56- * initial value.
57- *
58- * @developerPreview
38+ * Initializes a model of type `T` with an initial value of `undefined`.
39+ * Angular will implicitly use `undefined` as initial value.
5940 */
6041 < T > ( ) : ModelSignal < T | undefined > ;
42+ /** Initializes a model of type `T` with the given initial value. */
6143 < T > ( initialValue : T , opts ?: ModelOptions ) : ModelSignal < T > ;
6244
63- /**
64- * Initializes a required model.
65- *
66- * Users of your directive/component need to bind to the input side of the model.
67- * If unset, a compile time error will be reported .
68- *
69- * @developerPreview
70- */
71- required < T > ( opts ?: ModelOptions ) : ModelSignal < T > ;
45+ required : {
46+ /**
47+ * Initializes a required model.
48+ *
49+ * Users of your directive/component need to bind to the input side of the model .
50+ * If unset, a compile time error will be reported.
51+ */
52+ < T > ( opts ?: ModelOptions ) : ModelSignal < T > ;
53+ } ;
7254}
7355
7456/**
75- * `model` declares a writeable signal that is exposed as an input/output pair on the containing
76- * directive. The input name is taken either from the class member or from the `alias` option.
57+ * `model` declares a writeable signal that is exposed as an input/output
58+ * pair on the containing directive.
59+ *
60+ * The input name is taken either from the class member or from the `alias` option.
7761 * The output name is generated by taking the input name and appending `Change`.
7862 *
79- * Initializes a model with an initial value. If no explicit value
80- * is specified, Angular will use `undefined`.
63+ * @usageNotes
8164 *
82- * Consider using `model.required` for models that don't need an
83- * initial value.
65+ * To use `model()`, import the function from `@angular/core`.
8466 *
85- * @usageNotes
86- * Initialize a model in your directive or component by declaring a
87- * class field and initializing it with the `model()` or `model.required()`
88- * function.
67+ * ```
68+ * import {model} from '@angular/core`;
69+ * ```
70+ *
71+ * Inside your component, introduce a new class member and initialize
72+ * it with a call to `model` or `model.required`.
8973 *
9074 * ```ts
91- * @Directive ({..})
75+ * @Directive ({
76+ * ...
77+ * })
9278 * export class MyDir {
93- * firstName = model<string>(); // string|undefined
94- * lastName = model.required<string>(); // string
95- * age = model(0); // number
79+ * firstName = model<string>(); // ModelSignal<string|undefined>
80+ * lastName = model.required<string>(); // ModelSignal<string>
81+ * age = model(0); // ModelSignal<number>
82+ * }
83+ * ```
84+ *
85+ * Inside your component template, you can display the value of a `model`
86+ * by calling the signal.
87+ *
88+ * ```html
89+ * <span>{{firstName()}}</span>
90+ * ```
91+ *
92+ * Updating the `model` is equivalent to updating a writable signal.
93+ *
94+ * ```ts
95+ * updateName(newFirstName: string): void {
96+ * this.firstName.set(newFirstName);
9697 * }
9798 * ```
9899 *
99100 * @developerPreview
101+ * @initializerApiFunction
100102 */
101103export const model : ModelFunction = ( ( ) => {
102104 // Note: This may be considered a side-effect, but nothing will depend on
0 commit comments