Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
Angularjs ng模型负载设定值?_Angularjs - Fatal编程技术网

Angularjs ng模型负载设定值?

Angularjs ng模型负载设定值?,angularjs,Angularjs,我正在使用Angular js,我在typeahead中创建了一个带有列表的输入字段: <input type="materialid" ng-model="material" typeahead="material as material.ID for material in materials | filter:{ID:$viewValue} | limitTo:10" typeahead-editable="false" typeahead-min-length="0" /

我正在使用Angular js,我在typeahead中创建了一个带有列表的输入字段:

<input type="materialid" ng-model="material"  
typeahead="material as material.ID for material in materials | 
filter:{ID:$viewValue} | limitTo:10"  
typeahead-editable="false" typeahead-min-length="0" />
这是我的js:

$http.get('http://192.168.1.3/pesoweb/webservice/rest/materials',{ cache: true }).
success(function(dataList) {
    $scope.materials = dataList;
});

var id = 0;

$scope.linesTest = [
{id:id++, checked: "checked", type: "screwdrivers", tar:"0125", pesee:"21000", poids:"24545"},
{id:id++, checked: "", type: "handsaw", tar:"52632", pesee:"4524", poids:"24545"},
{id:id++, checked: "", type: "ALPHA", tar:"548485", pesee:"68465", poids:"75421"},
{id:id++, checked: "checked", type: "hammer", tar:"7825", pesee:"23541", poids:"74"}
];

$scope.addEmptyRow = function() {
  $scope.linesTest.push({id:id++, checked: "checked", type: "", tar:"", pesee:"", poids:""});
};

$scope.removeRow = function(id) {
  $scope.linesTest.remove(id);
};
我想在表中为数组中的每一行创建一行。 $scope.materials是一个JSON数组


您现在明白了吗?

您可以在
控制器中执行此操作:

$scope.material = 'screwdriver';

您可以在
控制器中执行此操作:

$scope.material = 'screwdriver';

您可以在
控制器中执行此操作:

$scope.material = 'screwdriver';

您可以在
控制器中执行此操作:

$scope.material = 'screwdriver';
使用

ng init=“材料=‘螺丝刀’”
使用

ng init=“材料=‘螺丝刀’”
使用

ng init=“材料=‘螺丝刀’”
使用

ng init=“材料=‘螺丝刀’”

+1。作为参考,也可以使用
ng init
,但建议不要这样做。官方文档()非常清楚,初始化应该在控制器中完成。是的,但我的输入是ng repeat。我从这个数组中逐行添加:$scope.linesTest=[{id:“1”,checked:“checked”,type:“螺丝刀”},{id:“2”,checked:,type:“手锯”},{id:“3”,checked:,type:“螺丝刀”},{id:“4”,checked:“checked”,type:“锤子”}@psv如果你的输入在ngRepeat内,我想你应该在你的问题中指出这一点。作为参考,也可以使用
ng init
,但建议不要这样做。官方文档()非常清楚,初始化应该在控制器中完成。是的,但我的输入是ng repeat。我从这个数组中逐行添加:$scope.linesTest=[{id:“1”,checked:“checked”,type:“螺丝刀”},{id:“2”,checked:,type:“手锯”},{id:“3”,checked:,type:“螺丝刀”},{id:“4”,checked:“checked”,type:“锤子”}@psv如果你的输入在ngRepeat内,我想你应该在你的问题中指出这一点。作为参考,也可以使用
ng init
,但建议不要这样做。官方文档()非常清楚,初始化应该在控制器中完成。是的,但我的输入是ng repeat。我从这个数组中逐行添加:$scope.linesTest=[{id:“1”,checked:“checked”,type:“螺丝刀”},{id:“2”,checked:,type:“手锯”},{id:“3”,checked:,type:“螺丝刀”},{id:“4”,checked:“checked”,type:“锤子”}@psv如果你的输入在ngRepeat内,我想你应该在你的问题中指出这一点。作为参考,也可以使用
ng init
,但建议不要这样做。官方文档()非常清楚,初始化应该在控制器中完成。是的,但我的输入是ng repeat。我从这个数组中逐行添加:$scope.linesTest=[{id:“1”,checked:“checked”,type:“螺丝刀”},{id:“2”,checked:,type:“手锯”},{id:“3”,checked:,type:“螺丝刀”},{id:“4”,checked:“checked”,type:“锤子”}@psv如果您的输入在ngRepeat中,我想您应该在问题中指出这一点。