I'm new to ionic/angularjs and I need to know how to display data to a HTML view from a Json url.
So, data in my Json URL looks like this:
{
News: [
{
id: "1",
title: " It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
image: "uploads/news/fortunaglobal_logo.jpg",
status: "yes"
},
{
id: "2",
title: "fgdf",
description: "hhjgh",
image: "uploads/news/16613_10204428208286459_7484489390034618482_n.jpg",
status: "yes"
}
]
}
I tried this in my script:
.controller('NewsCtrl', function($scope, $http) {
$http.get(' "JSON URL" ')
.success(function(response, status, headers, config){
window.alert('came in');
if(status==200){
$scope.news = response.data['News'];
window.alert($scope.news );
} else {
window.alert('No internet Connection');
}
console.log(news);
})
.error(function(data,status,headers,config){
window.alert('error '+data+status);
console.log(data);
console.log(status);
});
})
And this in my html page
<ion-view title="News" ng-controller="NewsCtrl">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content class="has-header" scroll="true" padding="true">
<ul ng-repeat="newsS in news">
<li>{{newsS.title}}</li>
</ul>
</ion-content>
</ion-view>
Can someone explain to me what I am doing wrong?
success
handler, if you have no connection it'll go intoerror
– Philipp Oct 2 '14 at 7:35