Javascript 在angularJs中创建动态元素,并以最佳方式使用ng模型
我想动态创建html输入元素并从中获取值 控制器:Javascript 在angularJs中创建动态元素,并以最佳方式使用ng模型,javascript,php,html,angularjs,input,Javascript,Php,Html,Angularjs,Input,我想动态创建html输入元素并从中获取值 控制器: $scope.itemElements = [{ "item": "item1", }, { "item": "item2", }, { "item": "item3", }]; $scope.saveQuotation = function() { console.log($scope.itemElements); } HTML: 如何获取动态创建和输入的所有值?数组$scope.itemElements
$scope.itemElements = [{
"item": "item1",
}, {
"item": "item2",
}, {
"item": "item3",
}];
$scope.saveQuotation = function() {
console.log($scope.itemElements);
}
HTML:
如何获取动态创建和输入的所有值?数组
$scope.itemElements
将具有更新的值。。。那么为什么您不能使用它呢?我如何从$scope.itemElements
angular.forEach($scope.itemElements,function(item,key){console.log(item.name)})打印单个值代码>获取未定义错误..`console.log(项)`
<tr ng-repeat="itemElemen in itemElements">
<td><input type="text" class="form-control" ng-model="itemElemen.item" placeholder="Enter item"/></td>
</tr>