Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. form: FormGroup;
  2.  
  3. ngOnInit() {
  4. this.form = this.fb.group({
  5. value: ['', [ Validators.required ], this.checkIfValueIsValid]
  6. });
  7. }
  8.  
  9. checkIfValueIsValid(control: AbstractControl) {
  10. return new Promise(resolve => {
  11. if (control.value === 'invalid_value') {
  12. resolve({ valueIsValid: true });
  13. } else {
  14. resolve(null);
  15. }
  16. });
  17. }
  18. <form [formGroup]="form">
  19. <div class="select-group">
  20. <label>Invalid/Valid</label>
  21. <cui-select formControlName="value">
  22. <cui-option [ngValue]="'invalid_value'">
  23. invalid
  24. </cui-option>
  25. <cui-option [ngValue]="'valid_value'">
  26. valid
  27. </cui-option>
  28. </cui-select>
  29. </div>
  30. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement