簡體   English   中英

Ionic 1.不起作用HTTP請求

[英]Ionic 1. Doesn't Work HTTP Request

我有一個問題,我不知道如何解決。

我在Ionic中有$ http.get(),當我進行離子服務時,它可以完美工作。 但是當我運行ios / android或在Ionic View中看到它時,什么也沒發生。

我的服務:

.service('myService', function($rootScope, $http, $q) {
    this.all = function() {
        var deferred = $q.defer();

        $http.get('xxxxxxxxxxxxxxx')
            .success(function(data) {
                deferred.resolve(data);
            })
            .error(function(data) {
                alert(data);
                deferred.reject(data);
            });
        return deferred.promise;
    };
});

在我的控制器中:

myService.all().then(function(data) {
       $scope.data = data;
});

當我在瀏覽器中打開時,顯示良好,在設備中,我收到帶有“ null”的警報。

我做:

離子更新

安裝cordova-plugin-whitelist

離子構建iOS / Android->離子上傳/離子運行

加:

<access origin="*" subdomains="true"/>
  <allow-navigation href="http://*/*"/>

在config.xml中

但是什么都行不通...知道嗎

非常感謝。

我嘗試了每個站點,但一無所獲。 有點奇怪

更新:我添加

<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-eval' 'unsafe-inline'">

和同一件事

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM