Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FormControl setValue
- setValue(value: any, options: {
- onlySelf?: boolean, // When true, each change only affects this control, and not its parent.
- emitEvent?: boolean, // When true or not supplied (the default),
- emitModelToViewChange?: boolean, // When true or not supplied (the default), each change triggers an `onChange` event
- emitViewToModelChange?: boolean // When true or not supplied (the default), each change triggers an `ngModelChange` event
- } = {}): void {
- // Update the value
- (this as{value: any}).value = this._pendingValue = value;
- // Notify others of the change if we are allowed to emit events
- if (this._onChange.length && options.emitModelToViewChange !== false) {
- // Loop through each of our onChange subscriber functions and call them to notify them of an update
- this._onChange.forEach(
- (changeFn) => changeFn(this.value, options.emitViewToModelChange !== false));
- }
- // update the form value and check it's validity, calling other validators if req.
- this.updateValueAndValidity(options);
- }
- /**
- * Patches the value of a control.
- * This function is functionally the same as setValue at this level.
- * It exists for symmetry with patchValue on `FormGroups` and `FormArrays`, where it does behave differently.
- */
- patchValue(value: any, options: {
- onlySelf?: boolean,
- emitEvent?: boolean,
- emitModelToViewChange?: boolean,
- emitViewToModelChange?: boolean
- } = {}): void {
- this.setValue(value, options);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement