1
我有一个表单,我动态地添加了域,但是当我尝试获取唯一的名称时它不工作,任何人都可以提前帮助我。找到下面我的代码。如何在角js中添加具有唯一名称的dyanamic表单域
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Angular Forms | Form2 </title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="js/angular.js"></script>
<script src="js/jquery-2.0.3.js"></script>
<script src="js/app2.js"></script>
</head>
<body>
<div ng-app="myApp2" ng-controller="myCtrl2">
<div class="container">
<div class="col-sm-9 col-sm-offset-2">
<form name="form1" ng-submit="submitForm2()" enctype="multipart/form-data">
<!--for adding extra fields data-->
{{count}}
<fieldset data-ng-repeat="choice in choices" ng-init="count=0">
<div class="form-group">
<div class="row">
<label class="col-md-2">Skills</label>
<div class="col-md-7">
<input type="text" class="form-control" name="skills" ng-focus="userskills_msg=true" ng-model="user2.skills" placeholder="Enter your skills" />
<p ng-show="errorSkill">{{errorSkill}}</p>
</div>
<div class="col-sm-3 col-md-3"> <span ng-cloak ng-show="userskills_msg"> please choose your location</span> </div>
<button class="remove" ng-show="$last" ng-click="removeChoice()">-</button>
</div>
</div>
</fieldset>
<!--end adding extra fields data-->
<div class="form-group">
<div class="col-md-3"></div>
<div class="col-md-6"> <a href="javascript:void(0);" id="add_emp" ng-click="addfields()">+add another employment</a><!--<button class="addfields" ng-click="addfields()">Add fields</button>--> </div>
</div>
</div>
</div>
</div>
</body>
</html>
我是初始化采用NG-初始化变量和我递增控制器,该值将incrementd但我是不是geeting唯一的名称和文件DIS不显示
var sampleApp = angular.module("myApp2", []);
sampleApp.controller("myCtrl2", function ($scope, $http) {
$scope.addfields = function() {
var newItemNo = $scope.choices.length + 1;
$scope.count = newItemNo;
console.log(count);
console.log(newItemNo);
$scope.choices.push({
'id' : 'choice' + newItemNo
});
};
$scope.removeChoice = function() {
var lastItem = $scope.choices.length - 1;
$scope.choices.splice(lastItem);
};
});
这是怎么问题有关PHP? – Dragos
您缺少表单结束标记,并且您的链接标题未终止。 –