这是我正在使用的代码...
var Agencyapp = angular.module('MainPage', ['restangular']);
angular.module('MainPage').controller('AgenciesCtrl', function ($scope, Restangular) {
Restangular.setBaseUrl('http://localhost/MappingServicesWebAPI/api');
$scope.Agencies = Restangular.all("mapping").get();
});
我很简单地试图返回一个代理 ID 和代理名称的列表。网址是正确的,当我将其粘贴到 Chrome 中时,它会返回正确的数据,但我收到错误“无法获取未定义或空引用的属性 'toString'”
不知道我做错了什么......
我已经把我的代码改成了这个......
var Agencyapp = angular.module('MainPage', ['restangular']);
angular.module('MainPage').controller('AgenciesCtrl',['$scope','Restangular', function ($scope, Restangular) {
Restangular.setBaseUrl('http://localhost/MappingServicesWebAPI/api');
Restangular.all('mapping');
var baseAccounts = Restangular.all('mapping');
baseAccounts.getList().then(function(gotAgencies){
var _Agencies = gotAgencies[0];
$scope.Agencies = _Agencies.getList('mapping');
});
}]);
现在我看到多个范围,前 2 个填充,其余为空,为什么会这样?
这就是 Scopes 在 chrome 中的样子......
< Scope (002)
< Scope (003)
< Scope (006)
< Scope (007)
< Scope (008)
< Scope (009)
< Scope (00A)
< Scope (00B)
< Scope (00C)
< Scope (00D)
< Scope (00E)
< Scope (00F)
< Scope (00G)
< Scope (00H)
< Scope (00I)
< Scope (00J)
< Scope (00K)
< Scope (00L)
< Scope (00M)
< Scope (00N)
< Scope (00O)
< Scope (00P)
< Scope (00Q)
< Scope (00R)
< Scope (00S)
< Scope (00T)
< Scope (00V)
< Scope (00W)
< Scope (00X)
< Scope (00Y)
< Scope (00Z)
< Scope (010)
< Scope (011)
< Scope (012)
< Scope (004)
范围 006 和 007 填充了数据,其余为空