Ionic value between two pages

Hello,
i am really new to ionic.what i am trying to do now is recover a value i passed from a page to another through the adress
image
i want to retrieve the last part which is the id of an article then use it to make a request to an api.
thank you

Hi @redamed92,

You can use the below mentioned code.

    $scope.$on('$ionicView.enter', function (event, data) {
      if(data.stateName == 'app.goalEdit') {
         $scope.Lastid = data.stateParams.coll_id
      }
    } 

This is my rounting for the example.

    .state('app.goalEdit', {
            url: '/goalEdit/:coll_id',
            views: {
              'menuContent': {
                templateUrl: 'app/components/goal/goalEdit.view.html',
                controller: 'GoalController as goal'
              }
            }
          })

Here data.stateParams.coll_id is the code which ca get you the id from the URL to you in edit goal controller.

Hope this will find the solution for your issue. You can always marke it as a solution and feel free to like the answer by pressing heart button.

i added your code.i understood that it will test the state name.then affect the id .the thing is i belive it will go into the 2nd page controller.how to pass to the page.just want to print.thank you for the time.after 3days of ionic training.i think it go like this $scope.go("pagename,id);

For passing value to another page you can use below mentioned code.

$scope.state.transitionTo('app.goalEdit', {coll_id: $scope.Lastid});

To use this code you need to inject $state dependency in your controller.

sorry for the delay.actually i moved on from that problem.just used $stateparams to get the id to test on it.
thanks again

Thanks,

Glad to know my provided solution worked for you.

Let us know any further assistance needed.