0

I am looping over Json array in view, I want to pass the item to another controller. How do I pass the item object (JSON) from html view page to another controller in ionic.

rentlist.html   
    <ion-item style="padding: 2px; border-width: 0px;" ng-repeat="acc in accs"
            item="acc" >
  <div id="wrapper" class="item item-word-wrap" ng-click="selectAcc(acc)">
<table style="table-layout: auto; width: 100%;">
            <tr>
              <td style="width: 25%;">
                <div id="first">
                    <img style="display: inline-block;" ng-src="{{acc.image}}">
                </div>
              </td>
              <td style="width: 55%; vertical-align: top;">
                <div id="second">
                  <div id="third">{{acc.title}}</div>
                  <div id="fourth">{{acc.address}}</div>
                  <div id="fifth"><a ng-href="#/detail/{{acc}}">View Details</a></div>
                </div>


 app.js
.state('detail', {
  url: '/detail/{acc:json}',
  templateUrl: 'js/detail.html',
  controller: 'detailCtrl'
  })

 detail.js 
$scope.accs = [];

$scope.accs = $stateParams.acc;

This is the JSON data which i need to send it to other controller 
<a ng-href="#/detail/{&quot;address&quot;:&quot;Lachs Straße&quot;,&quot;contact_number&quot;:&quot;0160933&quot;,&quot;description&quot;:&quot;Quiet and cozy flat with big windows and essential furniture.&quot;,&quot;title&quot;:&quot;Single-room apartment for three semesters&quot;,&quot;type&quot;:&quot;Flat&quot;,&quot;total_size&quot;:50,&quot;img&quot;:&quot;img/studierent_logo.png}
user2301
  • 1,857
  • 6
  • 32
  • 63
  • 1
    Possible duplicate of [Share data between AngularJS controllers](http://stackoverflow.com/questions/21919962/share-data-between-angularjs-controllers) – lin Mar 11 '17 at 19:17
  • Have you look at this? http://stackoverflow.com/questions/39420327/passing-parameters-data-to-controller-with-angular-ui-router-state – giaffa86 Mar 11 '17 at 19:19
  • I tried It didnt work. It is coming to Login page. I am displaying list of items. In each item, I have added a link, On click of it, should navigate to another view page. But this is not happening. – user2301 Mar 11 '17 at 20:11

0 Answers0