2015-11-06 89 views
0

下面的代碼在瀏覽器和iPhone 5s中工作,但不在iOS模擬器中工作。我試圖弄清楚它是模擬器還是離子模擬器。

我在Info.plist中設置NSAppTransportSecurity能夠使用http

NSAppTransportSecurity NSAllowsArbitraryLoads 和代碼:

accountRepo.register($scope.login.registryCode) 
.success(function(data){ 
    accountRepo.user = data; 
    $scope.hideLoading(); 
    $state.go("setPin"); 
}) 
.error(function(err){ 
    console.log(err); 
    $scope.hideLoading(); 
    alert("Incorrect registry code"); 
}); 

和回購

app.factory('accountRepo', function($http) { 
    return { 
    token: {}, 
    register: function(registryCode) { 
     return $http.post("http://localhost:9501/register", 
     {"registryCode": registryCode}); 
    }, 

錯誤發生錯誤時參數爲空。我在Xcode的輸出中沒有任何東西。我應該看看其他地方嗎?

回答

1

有點晚了,但有人可能會覺得這很有用。

當做ionic serveionic run -l時,這是跨源資源共享(CORS)的問題。

您可以通過在ionic.project中設置代理來解決該問題。

查看這篇文章的更多內容:http://blog.ionic.io/handling-cors-issues-in-ionic/

相關問題