0

I have implemented the web application in which we have passed the data from 1 view to another view but controller is same.i have tried but in case I got undefined value after the page is redirect.i don’t understand what ’s wrong in my code?

In below code $scope.selectedServiceId param will be undefined after page redirect i get this value how to get this value ?

    //assign the  diff parameter..
  $scope.setRatingToSelectedItem = function(value) {
      $scope.selectedServiceId = value;
  }
View 1 > ratingChart -
 call function and change view i have pass this data in another page
 view 2 > airtport 
 In this page we have receive the data but due to page redirection value will be undefined 

<button class="border-none white border-radius5 padding-tb10 padding-lr35
  bg_darkblue" ng-click="getDetailViaCategoryWise('Airport', airport)">
  <a href="#!airport?{{airport.id}}">
    <span style="color:white;">
      Rating Chart
    </span>
  </a>
  </button>
Kapil Soni
  • 963
  • 2
  • 12
  • 31
  • are you using $stateProvider or $routeProvider? – Ravikumar R Dec 13 '18 at 13:49
  • https://stackoverflow.com/questions/24526801/difference-between-ui-sref-and-state-go-in-angularjs-ui-router Hope this helps – Ravikumar R Dec 13 '18 at 13:52
  • @Ravikumar no sir i am not using both? – Kapil Soni Dec 13 '18 at 17:18
  • @Ravikumars :Sir i will check this link but i don't understand why we need to append the param to the URL? – Kapil Soni Dec 13 '18 at 18:19
  • there is no need to append the data in url, but if you want to share the data between controllers you have to use service or rootscope or localstorage, but you have mentioned that controller is same, so you can simply set the data in scope like `$scope.data = "yourdata"`. no need to pass the data in url. – Ravikumar R Dec 17 '18 at 11:10
  • sir i have already set the datain the $scope as well as $rootscope after page change var is undefined ? – Kapil Soni Dec 17 '18 at 11:12

0 Answers0