Ionic navigate to page with id from a page


#1

I have fetched json data from a url which contains data with unique id , I want to show more details about particular id in another page as like in ionic tabs demo template

app.js

     .state('tab.search', {
    url: "/search",
    views: {
      'tab-bus': {
        templateUrl: "templates/search.html",
        controller: 'SearchCtrl'
      }
    }
  })
.state('tab.bus-detail', {
      url: '/search/:busId',  //**How to get id from the json and pass it in busId**
      views: {
        'tab-bus': {
          templateUrl: 'templates/bus-detail.html',
          controller: 'BusDetailCtrl'
        }
      }
    })

controller.js

   .controller('SearchCtrl',['$scope','$http',function($scope,$http){
          $http.get("templates/search.json").success(function(response){$scope.bus=response.availableTrips;});     
      }])

#2

Here’s an article I wrote on this topic: http://www.gajotres.net/ionic-framework-tutorial-5-master-detail-pattern/

You’ll find everything there


#3

You can use something like this. Once you get the data from the server, store it in some service, and then you can use that data, which has the unique id, to navigate to the details view like $state.go('tab.bus-detail',{busId:idOfTheBusFromTheServer}). As you have a different controller for the details viewBusDetailCtrl, in that controller you can get the data stored in the service and you can show it on the details view.


#4

Thank you… I will check it