0

Maybe my issue seems easy to resolve, but I've this problem since a lot of hours : When I'm in my dashboard, all data of my Firebase database are visible (With Ng-repeat). But I can't found a solution for choose one specific item and see his details in another page.

I've test this method above and I've this error "Error: Could not resolve '#/tabpost' from state 'tabdash".

This is the HTML (This is an example) :

<div ng-repeat="post in posts">

<div class="card" ui-sref="#/post/{id}">
<h1>{{post.title}}</h1>
<p>{{post.content}}</p>
</div>

</div>

In App JS :

  .state('tabpost', {
  url: 'tabpost/id',
  templateUrl: 'templates/tab-post.html',
  controller: 'PostCtrl'
  })

In Service JS (in Post Factory) :

 myApp.factory("Post", ["$firebaseArray", "$firebaseObject", function($firebaseArray, $firebaseObject) {
var postRef = new Firebase('https://myApp.firebaseio.com/Posts/');
var userRef = new Firebase('https://myApp.firebaseio.com/Users/');
var posts = $firebaseArray(postRef);

     var Post = {

         all: posts,

         get: function (postKey){
          var postId = $firebaseObject(postRef);
                return $firebaseObject(eventRef.child('Posts').child(postId).child(userid));

              }
            ,
        add: function (post){
          var postId = $firebaseArray(postRef, userRef);
          event.userid = userRef.getAuth();
                return postId.$add(post);
              }
       }
       return Post;

}]);

My PostCtrl :

myApp.controller('PostCtrl', ['$ionicFrostedDelegate', '$ionicScrollDelegate','$state','$scope', 'Post', 'Auth', '$firebaseObject', '$firebaseArray', '$routeParams', function($ionicFrostedDelegate, $ionicScrollDelegate, $state,$scope, Post, Auth, $firebaseObject, $firebaseArray, $routeParams) {

  var PostRef = new Firebase("https://myApp.firebaseio.com/Posts");

var id = $routeParams.id; //get the id from url, $routeParams is injected in controller

  $state.go('tabpost', {
    id: $scope.id
  });

  $scope.posts = Post.get(id); //call get() method of Post with the id retrieved

  $scope.post = {'title': '', 'content': ''};

  $scope.auth = Auth;

PS : It took 3 days and night to try a bunch of tutorials mostly obsolete , and I am sure that the solution can not be that simple.

I already posted three similar issues yesterday and later but each of the proposed solutions have not worked . I would be immensely grateful to the person who would help me out of this impasse .

I still have a little trouble with jsFiddle promised I would learn to use it once I would have solved this problem.

Thank you for giving me time

PalmThreeStudio
  • 489
  • 8
  • 21

1 Answers1

0

You need to prefix your variable names with a colon in your state's URL. Your ui-router state should be

 .state('tabpost', {
  url: 'tabpost/:id',
  templateUrl: 'templates/tab-post.html',
  controller: 'PostCtrl'
  });

and you should link to it like

<div class="card" ui-sref="tabpost/{id}">
Graham T
  • 968
  • 9
  • 14