Angularjs ng使用多个名称重复多个文件,如append
我最近在angularjs上工作。目前,我将与ng repeat合作添加更多按钮。我想单击bootstrap添加多个generate div,div有三个输入字段1。姓名,2。说明,3。文件,但我的代码没有正确重复,请帮助我Angularjs ng使用多个名称重复多个文件,如append,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,我最近在angularjs上工作。目前,我将与ng repeat合作添加更多按钮。我想单击bootstrap添加多个generate div,div有三个输入字段1。姓名,2。说明,3。文件,但我的代码没有正确重复,请帮助我 Controller: // Add More Step Function $scope.step = { fields: [] }; $scope.addFormField = function() { $scope.step.fields.push('
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>
控制器:
//添加更多步骤功能
$scope.step={fields:[]};
$scope.addFormField=函数(){
$scope.step.fields.push(“”);
}
Html代码:
请参见演示代码:
将您的版本更改为(至少)1.2,它将正常工作,因为track by$index
是在该版本中引入的
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.step = { fields: [] };
$scope.addFormField = function() {
$scope.step.fields.push({});
}
});
请参阅演示代码:
将您的版本更改为(至少)1.2,它将正常工作,因为track by$index
是在该版本中引入的
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.step = { fields: [] };
$scope.addFormField = function() {
$scope.step.fields.push({});
}
});
你会做提琴或普朗克吗?不,我在本地主机上工作。我无法使用此代码创建fiddle或plunker抱歉:(请查看此URL:你的角度版本是什么???我做了类似的事情,并在上与你分享了你可以使用fiddle或plunker吗?不,我正在使用localhost。我无法使用此代码创建fiddle或plunker抱歉:(请看这个网址:什么是你的角度版本???我做了一些类似的事情,并在网站上与你分享。)