@Kotshgfx wrote:
I try to open details of news from archive, Now i am in home, And have categories in home page of my APP, Then when i click on any category we open all post in this category, Bu my problem now when click in single post, I cannot open it.
My view :
<a class="item" ng-repeat="post in allPosts" id="" href="#/allpost/details/{{post.id}}"> <div class="item item-body"> <div> <img ng-src="{{ post.thumbnail_images.medium.url }}" style=" max-width: 100% !important; max-height: 100% !important;" image-lazy-loader="ios" image-lazy-distance-from-bottom-to-load="-200" /> <div class="title-news"> <div class="title" ng-bind-html="post.title"></div> </div> </div> </div> </a>
My controller :
myApp.controller('details', function($scope, $http, $stateParams, News, $cordovaSocialSharing, $timeout, $ionicModal, $compile) { var id = $stateParams.id; $scope.post = News.GetSingleNews(id); $scope.share = function() { document.addEventListener("deviceready", function() { $cordovaSocialSharing.share($scope.post.title, $scope.post.content, null, "http://android-wd.net/" + $scope.post.title + " "); }, false); }; });
And my routes :
.state('app.home', { url: "/home", abstract: true, views: { 'home': { template: "<ion-nav-view></ion-nav-view>" } } }) .state('app.home.index', { url: '', templateUrl: 'js/app/views/home.html', controller: 'home' }) .state('app.allpost', { url: "/allpost", abstract: true, views: { 'allpost': { template: "<ion-nav-view></ion-nav-view>" } } }) .state('app.home.allpost', { url: '/allpost/:id', templateUrl: 'js/app/views/allpost.html', controller: 'allpost' }) .state('app.allpost.details', { url: '/details/:id', templateUrl: 'js/app/views/details.html', controller: 'details' })
and my services:
myApp.factory('News', ['$http', '$q', function($http, $q) { var news = []; var pages = null; return { GetNews: function(page) { return $http.get("http://android-wd.net/category/news?json=get_recent_posts&count=10&page=" + page, { params: null }).then(function(response) { items = response.data.posts; news = items; return items; }); }, GetMoreNews: function(page) { return $http.get("http://android-wd.net/category/news?json=get_recent_posts&count=10&page=" + page, { params: null }).then(function(response) { items = response.data.posts; news = news.concat(items); return items; }); }, GetSingleNews: function(id) { for (i = 0; i < news.length; i++) { if (news[i].id == id) { return news[i]; } } } } }])
Now How can open details of single post?
Posts: 1
Participants: 1