0
這是我用我簡單試圖返回agencID的和AgencyNames的列表的代碼...RestAngular多個領域創造了頂尖的產品填充其他空
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();
});
。 Url是正確的,當我將它粘貼到Chrome中時,它會返回正確的數據,但我收到錯誤「Unable to get property'toString'of undefined or null reference」
不知道我在做什麼錯誤.. 。
我已經改變了我的代碼,這...
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填充和空的其餘部分, 爲什麼會變成這樣?
這就是作用域看起來像鉻...
< 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都填充了數據,其餘均爲無效
嘿, 在你使用get來獲取元素的列表的第一個例子,所以這是出了什麼問題。其餘的,我不知道你想要獲取什麼,但第一個案例會做一個GET:'http:// localhost/MappingServicesWebAPI/api/mapping',我不知道這是否是這個想法。但Restangular不創建任何範圍,所以我不知道發生了什麼 – mgonto
我改變代碼的方式是否正確?你有任何疑難解答提示? – TJunky