我有一個存儲對一個未定義的數字形式:標籤/值:角2追加點擊按鈕
<form (submit)=new_answers_for_this_question()>
<div class="row">
<div class="input-field col m5">
<input placeholder="Label" id="label" type="text" class="validate">
</div>
<div class="input-field col m5">
<input placeholder="Value" id="values" type="text" class="validate">
</div>
<div class="input-field col m2 center-align">
<button class="btn-floating waves-effect waves-light" (click)="new_answer()"><i class="material-icons">add</i></button>
</div>
</div>
<button>Insert Answers</button>
</form>
我只是想填補這兩個輸入,然後按add button
添加一個新行用新的標籤/值input
,之前的add button
會消失,並且新增一個新按鈕來追加新的可能的行。使用jQuery
很簡單,因爲append
父div上的整行div,但使用角度我不知道如何處理這個問題,¿任何想法?
編輯:其目的是爲DataBase中相同問題的每對標籤和值插入一行。
即:
**Question 1**
Label: 'good', value: '7-10'
Label: 'neutral', Value: '4-6'
Label: 'bad', Value: '1-3'
使用循環('* ngFor')在用戶按下「添加」時添加項目的數組上。 – 2017-06-05 12:26:01
但第一次我需要一個輸入,第一次循環時將是空的,然後沒有輸入顯示 – PriNcee