Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.88 KB | None | 0 0
  1. <div class="container">
  2.   <div class="row">
  3.     <div class="col-xs-12 col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2">
  4.       <!-- This is how you get access to the form created by angular automatically
  5.      using the #f="ngForm", the f can be anything -->
  6.       <form (ngSubmit)="onSubmit(f)" #f="ngForm">
  7.         <div id="user-data" ngModelGroup="userData">
  8.           <div class="form-group">
  9.             <label for="username">Username</label>
  10.             <!-- ngModel lets angular know that this input is a control of our form. -->
  11.             <input
  12.             type="text"
  13.             id="username"
  14.             class="form-control"
  15.             ngModel
  16.             name="username"
  17.             required
  18.             #user="ngModel">
  19.              <span class="help-block" *ngIf="!user.valid && user.touched">
  20.                Please enter a valid username
  21.              </span>
  22.           </div>
  23.           <button class="btn btn-default" type="button" (click)="suggestUserName()">Suggest an Username</button>
  24.           <div class="form-group">
  25.             <label for="email">Mail</label>
  26.             <input
  27.             type="email"
  28.             id="email"
  29.             class="form-control"
  30.             ngModel
  31.             name="email"
  32.             required
  33.             email
  34.             #email="ngModel">
  35.              <span class="help-block" *ngIf="!email.valid && email.touched">
  36.                Please enter a valid email
  37.              </span>
  38.           </div>
  39.         </div>
  40.         <div class="form-group">
  41.           <label for="secret">Secret Questions</label>
  42.           <!-- Select is just another type of HTML input -->
  43.           <select
  44.           id="secret"
  45.           class="form-control"
  46.           [ngModel]="defaultQuestion"
  47.           name="secret">
  48.             <option value="pet">Your first Pet?</option>
  49.             <option value="teacher">Your first teacher?</option>
  50.           </select>
  51.         </div>
  52.         <div class="form-group">
  53.           <textarea class="form-control" name="questionAnswer" rows="3" [(ngModel)]="answer">
  54.  
  55.           </textarea>
  56.         </div>
  57.         <p>Youre reply: {{ answer }}</p>
  58.         <div class="radio" *ngFor="let gender of genders">
  59.           <label>
  60.             <input type="radio" name="gender" ngModel [value]="gender">
  61.             {{ gender }}
  62.           </label>
  63.         </div>
  64.         <button
  65.          class="btn btn-primary"
  66.          type="submit"
  67.          [disabled]="!form.valid">Submit</button>
  68.       </form>
  69.     </div>
  70.   </div>
  71.   <hr>
  72.   <div class="row" *ngIf="submitted">
  73.     <div class="col-xs-12">
  74.         <h3>Your Data</h3>
  75.         <p>Username: {{ user.username }}</p>
  76.         <!-- <p>Mail: {{ user.value.email }}</p> -->
  77.         <!-- <p>secret: {{ user.secret }}</p>
  78.        <p>answer: {{ user.answer }}</p>
  79.        <p>gender: {{ user.gender }}</p> -->
  80.     </div>
  81.   </div>
  82. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement