我正在研究angularjs。目前我将开始使用ng-repeat添加更多按钮。我想点击bootstrap添加多于生成div和div有三个输入字段1.名称,2。描述,3。文件但我的代码不能正确重复请帮帮我。
Controller:
// Add More Step Function
$scope.step = { fields: [] };
$scope.addFormField = function() {
$scope.step.fields.push('');
}
Html Code:
<div ng-repeat="field in step.fields track by $index">
<div id="div{{6+$index}}">
<div class="form-group col-sm-4">
<!--<input type="text" class="form-control" ng-model="process.process.step.name5" placeholder="Step Name">-->
<input type="text" class="form-control" ng-model='process.process.step.fields[$index]' placeholder="Step Name">
</div>
<div class="form-group col-sm-4">
<!--<input type="text" class="form-control" ng-model="process.process.step.description5" placeholder="Step Description">-->
<input type="text" class="form-control" ng-model='process.process.step.fields[$index]' placeholder="Step Description">
</div>
<div class="form-group col-sm-4">
<!--<input data-my-Directive class="form-control" type="file" id="file5" name="file5" ng-click="uploadFile('file5');" />-->
<input data-my-Directive class="form-control" type="file" id="file{{6+$index}}" name="file{{$index}}" ng-click="uploadFile('file{{$index}}');" />
<input type="hidden" value="{{imageName}}" ng-model="process.process.step.file"/>
</div>
</div>
</div>