i have this steps to get posts of category from Json API WordPress, And my problem is cannot print post title and content in page but in console i get it.
My code:-
myApp.factory('Allposts',['$http', '$q',function($http,$q){
var allposts = [];
var pages = null;
return {
GetAllposts: function (id) {
return $http.get("http://localhost/khaliddev/azkarserv/?json=get_category_posts&id="+id+"&status=publish",{params: null}).then(function (response) {
items = response.data.posts;
console.log(items);
allposts = items;
return items;
});
}
}
}]);
The http://localhost/khaliddev/azkarserv/?json=get_category_posts&id=16&status=publish
is like
{"status":"ok","count":1,"pages":1,"category":{"id":16,"slug":"%d8%a3%d8%b0%d9%83%d8%a7%d8%b1-%d8%a7%d9%84%d8%a7%d8%b3%d8%aa%d9%8a%d9%82%d8%a7%d8%b8","title":"\u0623\u0630\u0643\u0627\u0631 \u0627\u0644\u0627\u0633\u062a\u064a\u0642\u0627\u0638","description":"","parent":0,"post_count":1},"posts":[{"id":31,"type":"post","slug":"%d8%a3%d8%b0%d9%83%d8%a7%d8%b1-%d8%a7%d9%84%d8%a7%d8%b3%d8%aa%d9%8a%d9%82%d8%a7%d8%b8","url":"http:\/\/localhost\/khaliddev\/azkarserv\/2015\/08\/28\/%d8%a3%d8%b0%d9%83%d8%a7%d8%b1-%d8%a7%d9%84%d8%a7%d8%b3%d8%aa%d9%8a%d9%82%d8%a7%d8%b8\/","status":"publish","title":"\u0623\u0630\u0643\u0627\u0631 \u0627\u0644\u0627\u0633\u062a\u064a\u0642\u0627\u0638","title_plain":"\u0623\u0630\u0643\u0627\u0631 \u0627\u0644\u0627\u0633\u062a\u064a\u0642\u0627\u0638","content":"<p>\u0627\u0644\u062d\u0645\u0640\u062f \u0644\u0644\u0647 \u0627\u0644\u0630\u064a \u0623\u062d\u0640\u064a\u0627\u0646\u0627 \u0628\u0639\u0640\u062f \u0645\u0627 \u0623\u0645\u0627\u062a\u0640\u0646\u0627 \u0648\u0625\u0644\u064a\u0647 \u0627\u0644\u0646\u0640\u0634\u0648\u0631.<\/p>\n","excerpt":"<p>\u0627\u0644\u062d\u0645\u0640\u062f \u0644\u0644\u0647 \u0627\u0644\u0630\u064a \u0623\u062d\u0640\u064a\u0627\u0646\u0627 \u0628\u0639\u0640\u062f \u0645\u0627 \u0623\u0645\u0627\u062a\u0640\u0646\u0627 \u0648\u0625\u0644\u064a\u0647 \u0627\u0644\u0646\u0640\u0634\u0648\u0631.<\/p>\n","date":"2015-08-28 23:14:11","modified":"2015-08-28 23:14:11","categories":[{"id":16,"slug":"%d8%a3%d8%b0%d9%83%d8%a7%d8%b1-%d8%a7%d9%84%d8%a7%d8%b3%d8%aa%d9%8a%d9%82%d8%a7%d8%b8","title":"\u0623\u0630\u0643\u0627\u0631 \u0627\u0644\u0627\u0633\u062a\u064a\u0642\u0627\u0638","description":"","parent":0,"post_count":1}],"tags":[],"author":{"id":1,"slug":"azkarserv","name":"azkarserv","first_name":"","last_name":"","nickname":"azkarserv","url":"","description":""},"comments":[],"attachments":[],"comment_count":0,"comment_status":"open","custom_fields":{}}]}
and view is
<ion-view view-title="">
<ion-nav-title>
<img class="logo" src="img/logo.png">
</ion-nav-title>
<ion-content class="padding" lazy-scroll>
<div class="row no-padding HomeRowsList">
<dive class="item itemfull" ng-repeat="post in allposts">
<div class="item item-body">
<div>
{{ post.title }}
<div class="title-news">
<div class="title" ng-bind-html="post.content"></div>
</div>
</div>
</div>
</div>
</div>
</ion-content>
</ion-view>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire