daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form
  2.       [formGroup]="signUpForm"
  3.       (ngSubmit)="onSubmit()">
  4.  
  5.         <div class="radio">
  6.           <div *ngFor="let gender of genderValues">
  7.             <label>
  8.               <input
  9.                 formControlName="gender"
  10.                 value="{{gender}}"
  11.                 type="radio"
  12.                 name="gender"
  13.                 (change)="radioChangeHandler($event)">
  14.               {{gender === 'Male' ? 'Hombre' : 'Mujer'}}
  15.             </label>
  16.           </div>
  17.         </div>
  18. </form>
  19.    
  20. signUpForm: FormGroup;
  21. genderValues = ['Male', ' Female'];
  22.  
  23. this.signUpForm = this.formBuilder.group({
  24.       // Asigno un gender como default
  25.       gender: [this.genderValues[0], [
  26.         Validators.required
  27.       ]]
  28.     });
  29.  
  30. radioChangeHandler(event: any) {
  31.     // Guardar value nuevo
  32.     this.gender.setValue(event.target.value);
  33.     console.log(this.gender.value);
  34.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top