Hi Stackoverflow members,
I've set up a codepen here: Link Which works perfectly. However, when i try to implement this into my Ionic application it cannot receive the JSON data even though the code is almost exactly the same and i cannot understand why it's not working.
<body ng-controller="Controller">
<ion-view view-title="Announcements">
<ion-content class="padding">
<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="doRefresh()">
</ion-refresher>
<ion-list>
<ion-item ng-repeat="data in data">
<div class="list card">
<div class="item item-divider">{{data.announcement_name}} - {{data.date}}</div>
<div class="item item-body">
<div>
{{data.message}}
</div>
</div>
</div>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
</body>
And here's the controller:
angular.module('ionicApp', ['ionic'])
.controller('Controller', ['$http', '$scope', function ($http, $scope) {
$scope.data = [];
$scope.doRefresh = function () {
$http.get('https://api.myjson.com/bins/3z1eg')
.success(function (data) {
$scope.data = data;
})
.finally(function () {
$scope.$broadcast('scroll.refreshComplete');
});
};
}]);
I don't get any errors in console log when i run the code (which is annoying) so i have no idea what the problem is. Any help would be brilliant. Thanks.
You may need to white-list the address you're trying to access. This plugin allows you to white-list addresses. For a catch-all solution you can add the following to your config.xml:
<allow-intent href="*" />
Note however, this is not recommended. See the documentation for how to allow more specific URLs / protocols.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.