$ scope返回null对象和undefined

时间:2017-05-04 10:20:13

标签: angularjs

我从ng-model ng-repeat获取了ID,并尝试将其添加到$scope 但是scope返回null,每个id都为null,因为我的id是659和848,所以它从1开始,并将null放到除了存在的每个id之外。

<div ng-repeat="x in items">
<input type="text" name="item_id" ng-model="ItemProd[x.item_id][$index]">
<input type="submit">
<div>

console.log($scope.ItemProd);

的控制台中输出
array(849) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> ...... 
NULL [658]=> NULL [659]=> **object(stdClass)#34 (1) { ["0"]=> string(3) "666"** } [660]=> NULL ......
[841]=> NULL [842]=> NULL [843]=> NULL [844]=> NULL [845]=> NULL [846]=> NULL [847]=> NULL **[848]=> object(stdClass)#35 (1) { ["1"]=> string(3) "777"** } }

1 个答案:

答案 0 :(得分:1)

试试这个

在您的控制器中

none