我是新来的离子型/ angularjs,我需要知道如何显示数据从一个JSON URL一个HTML视图。显示数据
所以,在我的Json URL数据是这样的:
{
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"
}
]
}
我在我的脚本尝试这样做:
.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);
});
})
这在我的html页面
<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>
灿有人向我解释我做错了什么?
我不熟悉的离子,而是为了让自己的代码更简单,你不必检查在'success'处理器的状态,如果你没有连接,它会进入'error' – Philipp 2014-10-02 07:35:54
你能请添加更多关于您希望我们回答的信息? – magnudae 2014-10-02 07:39:09
我想在我的json中使用angularjs在html视图中显示数据 – CraZyDroiD 2014-10-02 08:08:39