Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. //FormControl setValue
  2. setValue(value: any, options: {
  3. onlySelf?: boolean, // When true, each change only affects this control, and not its parent.
  4. emitEvent?: boolean, // When true or not supplied (the default),
  5. emitModelToViewChange?: boolean, // When true or not supplied (the default), each change triggers an `onChange` event
  6. emitViewToModelChange?: boolean // When true or not supplied (the default), each change triggers an `ngModelChange` event
  7. } = {}): void {
  8. // Update the value
  9. (this as{value: any}).value = this._pendingValue = value;
  10.  
  11. // Notify others of the change if we are allowed to emit events
  12. if (this._onChange.length && options.emitModelToViewChange !== false) {
  13.  
  14. // Loop through each of our onChange subscriber functions and call them to notify them of an update
  15. this._onChange.forEach(
  16. (changeFn) => changeFn(this.value, options.emitViewToModelChange !== false));
  17. }
  18. // update the form value and check it's validity, calling other validators if req.
  19. this.updateValueAndValidity(options);
  20. }
  21.  
  22. /**
  23. * Patches the value of a control.
  24. * This function is functionally the same as setValue at this level.
  25. * It exists for symmetry with patchValue on `FormGroups` and `FormArrays`, where it does behave differently.
  26. */
  27. patchValue(value: any, options: {
  28. onlySelf?: boolean,
  29. emitEvent?: boolean,
  30. emitModelToViewChange?: boolean,
  31. emitViewToModelChange?: boolean
  32. } = {}): void {
  33. this.setValue(value, options);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement