$stateProvider navigation routing [Problem]

Hello guys, I am creating a RSS feed app but I don’t how to fix when clicking in an item to get to it’s html page by some
a href="#/singlepost/{{$id}}"

Can someone please help me solve this?

Here is my App.js:



var app = angular.module('starter', ['ionic']);

app.config(function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/')

  $stateProvider
	  .state('home', {
	    url: '/',
		controller: 'RSSCtrl', 
	    templateUrl: 'home.html'
	  })
	  .state('app.posts', {
		url: '/singlepost/:id',
		controller: 'PostCtrl', 
		templateUrl: 'singlepost.html',
	  });
});

app.controller('RSSCtrl', function($scope, $http, $rootScope) {
	
	$http.get("http://ideiasfmc.com/blog/api/get_posts/")
	.success(function(response) {
	
	$scope.postscope = response.posts;

	});

	// $scope.browse = function(v) {
	// window.open(v, "_blank", "location=yes");
	// };
	//working: opens website
	

});

app.controller('PostCtrl', function($scope, $stateParams, $rootScope) {
	
	$scope.index = $stateParams.index;
	

})


And here is my home.html file:
<ion-content class="padding">

  <ion-list class="list list-inset">

    <ion-item ng-repeat="post in postscope" class="item item-thumbnail-left" href="#/singlepost/{{post.id}}">
      <img src="{{post.thumbnail_images.full.url}}">
      <h2>Título: {{post.title}}</h2>
      <p>{{post.excerpt}}</p>
      <br>
    </ion-item>
  </ion-list>

</ion-content>

Thanks.

Are you getting what you think you should be getting in your link with the post id?

What you have there is /{{$post.id}} Should that $ be there?

1 Like

Hello Jonny, I removed the “$” from the {{}} and it stills doesn’t work, I think the problem now is here:


app.controller('PostCtrl', function($scope, $stateParams, $rootScope) {
	
	$scope.index = $stateParams.index;
	

})