Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在angularJs中创建动态元素,并以最佳方式使用ng模型_Javascript_Php_Html_Angularjs_Input - Fatal编程技术网

Javascript 在angularJs中创建动态元素,并以最佳方式使用ng模型

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

我想动态创建html输入元素并从中获取值

控制器:

$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>