3 回答

TA貢獻1848條經(jīng)驗 獲得超10個贊
看到這個柱塞
這是您所需要的示例。正如您在插件中看到的那樣,TextArea單擊按鈕時可以動態(tài)創(chuàng)建一個。單擊按鈕TextAreas也可以刪除創(chuàng)建的內(nèi)容remove。
請參閱下面的HTML
<div class="col-sm-10">
<input type="button" class="btn btn-info" ng-click="addNewChoice()" value="ADD QUESTION">
<div class="col-sm-4">
<fieldset data-ng-repeat="field in choiceSet.choices track by $index">
<textarea rows="4" cols="50" ng-model=" choiceSet.choices[$index]"></textarea>
<button type="button" class="btn btn-default btn-sm" ng-click="removeChoice($index)">
<span class="glyphicon glyphicon-minus"></span> REMOVE
</button>
</fieldset>
</div>
</div>
和JS將如下
var app = angular.module('myApp', []);
app.controller('inspectionController', function($scope, $http) {
$scope.choiceSet = {
choices: []
};
$scope.quest = {};
$scope.choiceSet.choices = [];
$scope.addNewChoice = function() {
$scope.choiceSet.choices.push('');
};
$scope.removeChoice = function(z) {
$scope.choiceSet.choices.splice(z, 1);
};
});
- 3 回答
- 0 關(guān)注
- 780 瀏覽
添加回答
舉報