module.controller('HomeController', function($scope, $http) {
$http.get('http://104.155.209.198/list/json')
.success(function (data) {
$scope.home_items = data;
console.log('call HomeController');
})
.error(function (error) {
$scope.error = "error";
});
$scope.ClickHome = function (url) {
$http.get('http://104.155.209.198'+url+'/json')
.success(function (data) {
$scope.list_items = data;
console.log($scope.list_items);
console.log('call ListItems');
});
};
$scope.ClickList = function (url) {
$http.get('http://104.155.209.198'+'/list'+url+'/json')
.success(function (data) {
$scope.viewObject = data;
console.log($scope.viewObject);
console.log('call ViewItems');
})
};
});
这是我的Angular代码。这项工作在WebBrowers中,但不适用于ios-emulate。什么问题?在onsen-ui上没有工作$ http?
答案 0 :(得分:0)
问题可能是加载外部内容。
您可以使用Safari检查问题。如果是这种情况,这可能会有所帮助:http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
将此添加到platforms/ios/<appname>/<appname>-Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
答案 1 :(得分:0)
新版本的onsen ui在模拟android
中不支持$ http$http({
method: 'POST',
data: 'Username=' + $scope.user.email + '&Password=' + $scope.user.password + '&is_varified='+$scope.user.is_varified+'&gcm_reg_id='+gcm_reg_id,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: myService.ajax_base_url+'/login/validate_mobile_user'
}).
success(function(data, status, headers, config) {
//console.log(data);
alert('in success');
modal.hide();
}).
error(function(data, status, headers, config) {
modal.hide();
alert('in error');
});