我是新來的離子型/ 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