【发布时间】:2016-10-23 12:40:16
【问题描述】:
我有一个问题,我不知道如何解决它。
我在 Ionic 中有 $http.get(),当我执行 ionic serve 时,它可以完美运行。但是当我运行 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 中
但没有任何效果......有什么想法吗?
非常感谢。
【问题讨论】:
-
什么都没有:/我不知道该怎么办