与 ng-options 中的硬编码 json 相比,解析动态 json 时出错

Error resolving my dynamic json compared to hardcoded json in ng-options

我有一个列表框,我正在绑定来自控制器的项目列表。

$scope.AvailableListItems = [
    [{Id:1,SupplierName: 'john.banks'},
    {Id: 2,SupplierName: 'jim.chevy'}, 
    {Id: 3,SupplierName: 'ralph.stocks'}]
];

这是硬编码的 json。当我用下面的 html 尝试这个时,它工作得非常好

<select multiple id="availabelist" size="10" style="width:100%" ng-change="OnAvailableChange()" ng-model="SelectedAvailItems" ng-options="i as i.email for i in AvailableListItems[selectFaIndex]| filter:availablequery"></select>

但是,当我尝试动态生成相同的东西时,它根本不起作用。得到一个空白列表框。 代码如下

 var getSuppliers = function () {  
            var tempArray = [];
            var lstsuppliers = CRUDService.getApiOutput(getSuppliersApiRoute);
            lstsuppliers.then(
                function (response) {
                    debugger;
                    $scope.supplierList = response.data;
                    for (var i = 0; i < $scope.supplierList.length; i++) {
                        arr = {};
                        arr["Id"] = $scope.supplierList[i].supplierId;
                        arr["SupplierName"] = $scope.supplierList[i].supplierName;
                        tempArray.push(arr);
                    }
                    $scope.AvailableListItems = tempArray;
                    console.log(JSON.stringify($scope.AvailableListItems));
                },
                function (error) {
                    console.log("Error: " + error);
                });
}

请帮我找出代码中的问题。

Working Plunk link

这是我的响应数据的样子:根据 Claies 更新

[{"Id":1,"SupplierName":"ACECO PRECISION MANUFACTURING"},{"Id":2,"SupplierName":"Pentagon EMS Corporation"},{"Id":3,"SupplierName":"QUANTUMCLEAN"},{"Id":4,"SupplierName":"MODERN CERAMICS"},{"Id":5,"SupplierName":"NXEDGE INC"}]

一起破解了几个小时,终于找到了解决办法。 我已将硬编码值和动态值放在一起进行控制台。我发现了以下差异。

我修改了

$scope.AvailableListItems = tempArray;

$scope.AvailableListItems.push(tempArray);

第 14 行,它成功了。 我更改代码后的输出是这样的

特别感谢@Tomas 和@Claies。