How can I implement Add More form inputs kind of function using ionic framework and angularjs?
Should be like this -
http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove-bs3
How can I implement Add More form inputs kind of function using ionic framework and angularjs?
Should be like this -
http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove-bs3
Just define an array with inputs, and loop through them to display:
$scope.inputs = [
{ value: null }
];
$scope.addInput = function () {
$scope.inputs.push({ value: null });
}
$scope.removeInput = function (index) {
$scope.inputs.splice(index, 1);
}
And in your view:
<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>
See this jsfiddle