How to create a page push in angularjs using the ionic framework?


#1

The idea is that when you click this item, I am taken to a page post.html
I have the following structure
Controller.js

.controller('newsController', ['$http', '$scope', '$rootScope', function ($http, $scope, $rootScope) { 
....
 $scope.showPost = function (index) {
 $rootScope.postContent = $scope.items[index];
 $scope.navi.pushPage('post.html'); //this does not work, I want to create something to take me to that page
};
}])

posts.html

<ion-item ng-click="showPost($index)">
    <img ng-show="{{ item.thumbnail_images }}" ng-src="{{ item.thumbnail_images.thumbnail.url }}"
         class="thumbnail is-loading" img-cache>

<h2> {{ item.title | limitTo: 22 }}...</h2>
<i class="icon ion-ios-pricetag-outline"> <span ng-repeat="cat in item.categories">{{cat.title}} </span> </i>
<p>{{ item.excerpt | htmlToPlaintext | limitTo: 60 }}...</p>
</ion-item>

#2

So you wouldn’t need to use $scope.navi.pushPage, you can use ng-href or ui-sref’s for this.

If you need to pass data between these views, you can take a look at the starter template for tabs.