Project

General

Profile

1
<form [formGroup]="myForm">
2
    <div class="form-group required" [ngClass]="{'has-error':!myForm.controls.question.valid && myForm.controls.question.dirty}">
3
        <label for="questionTag">Question</label>
4
        <textarea class="form-control" formControlName="question" id="questionTag" placeholder="Question" rows="2"></textarea>
5
    </div>
6
    <div class="form-group required" [ngClass]="{'has-error':!myForm.controls.answer.valid && myForm.controls.answer.dirty}">
7
        <label for="answerTag">Answer</label>
8
        <textarea class="form-control" formControlName="answer" id="answerTag" placeholder="Answer" rows="3"></textarea>
9
    </div>
10
    <div class="form-group" [ngClass]="{'has-error':!myForm.controls.weight.valid && myForm.controls.weight.dirty}">
11
        <label for="topicWeightTag">Weight</label>
12
        <input type="number" step="0.1" class="form-control" formControlName="weight" id="topicWeightTag" placeholder="Topic Weight (e.g. 3.5)">
13
    </div>
14
    <div class="form-group">
15
        <label>Select Status</label>
16
        <label class="checkbox">
17
            <span style="font-weight: normal;">Active</span>
18
            <input tabindex="0" type="checkbox" formControlName="isActive">
19

    
20
        </label>
21
    </div>
22

    
23
    <div class="form-group required" [ngClass]="{'has-error':!myForm.controls.weight.valid && myForm.controls.weight.dirty}">
24
        <label for="topicTag">Select Topic(s)</label>
25
        <select multiple formControlName="topics" id="topicTag" class="form-control">
26
            <option *ngFor="let topic of availableTopics" [value]="topic._id">{{topic.name}}</option>
27
        </select>
28
        <small class="form-text text-muted">Press <kbd>ctrl</kbd> + <kbd>click</kbd> to select more than one</small>
29
    </div>
30
    <input type="hidden" formControlName="_id">
31
</form>
32
<!--<pre>-->
33
<!--{{myForm.value | json}} |-->
34
    <!--{{myForm.valid}}-->
35
<!--</pre>-->
(1-1/8)