【发布时间】:2015-07-23 15:09:57
【问题描述】:
如何使用 ionic 框架和 angularjs 实现添加更多表单输入类型的功能?
应该是这样的——
http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove-bs3
【问题讨论】:
如何使用 ionic 框架和 angularjs 实现添加更多表单输入类型的功能?
应该是这样的——
http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove-bs3
【问题讨论】:
只需定义一个带有输入的数组,然后循环显示:
$scope.inputs = [
{ value: null }
];
$scope.addInput = function () {
$scope.inputs.push({ value: null });
}
$scope.removeInput = function (index) {
$scope.inputs.splice(index, 1);
}
在你看来:
<div ng-repeat="input in inputs">
<input type="text"
ng-model="input.value" />
<button ng-if="$index == inputs.length - 1"
ng-click="addInput()">+</button>
<button ng-if="$index != inputs.length - 1"
ng-click="removeInput($index)">-</button>
</div>
【讨论】: