|
1 | 1 | <h3>New Task Form</h3> |
2 | 2 |
|
3 | | -<div> |
4 | | - <label>Name: </label> |
5 | | - <input placeholder="Item Title" class="form-control" |
6 | | - [(ngModel)]="item.title" |
7 | | - required minlength="2" maxlength="23" |
8 | | - #title='ngModel'> |
9 | | - |
10 | | - <div *ngIf="title.dirty || title.touched"> |
11 | | - <p *ngIf='title.errors; then errors else valid'>template renders here...</p> |
12 | | - </div> |
13 | | - |
14 | | - <br> |
15 | | - <label>Body: </label> |
16 | | - <textarea placeholder="Item Body" class="form-control" |
17 | | - [(ngModel)]="item.body" |
18 | | - required minlength="2" maxlength="23" |
19 | | - #body='ngModel'> |
20 | | - </textarea> |
21 | | - <br> |
22 | | - <button (click)='createItem()' [disabled]="!title.valid || !body.valid">Create</button> |
| 3 | +<div class='form-group'> |
| 4 | + <fieldset> |
| 5 | + <label class="control-label">Name: </label> |
| 6 | + |
| 7 | + <input placeholder="Item Title" class="form-control" |
| 8 | + [(ngModel)]="item.title" |
| 9 | + required minlength="2" maxlength="23" |
| 10 | + #title='ngModel'> |
| 11 | + |
| 12 | + <div *ngIf="title.dirty"> |
| 13 | + <span *ngIf='title.errors; then errors else valid'>template renders here...</span> |
| 14 | + </div> |
| 15 | + |
| 16 | + <!-- <br> |
| 17 | + <label class="control-label">Body</label> |
| 18 | + <textarea placeholder="Item Body" class="form-control" rows="5" |
| 19 | + [(ngModel)]="item.body" |
| 20 | + required minlength="5" maxlength="200" |
| 21 | + #body='ngModel'> |
| 22 | + </textarea> |
| 23 | +
|
| 24 | + <div *ngIf="body.dirty"> |
| 25 | + <span *ngIf='body.errors; then errors else valid'>template renders here...</span> |
| 26 | + </div> --> |
| 27 | + |
| 28 | + |
| 29 | + <button class="btn btn-primary" (click)='createItem()' [disabled]="!title.valid">Create</button> |
| 30 | + </fieldset> |
23 | 31 | </div> |
24 | 32 |
|
25 | | -<ng-template #valid>looks good!</ng-template> |
26 | | -<ng-template #errors>form contains errors!</ng-template> |
| 33 | +<ng-template #valid> |
| 34 | + <p class="text-success">looks good!</p> |
| 35 | +</ng-template> |
| 36 | + |
| 37 | +<ng-template #errors> |
| 38 | + <p class="text-danger">form contains errors!</p> |
| 39 | +</ng-template> |
0 commit comments