angularjs - Passing values between html files -
i making shopping application in ionic/ angular js. want pass value (name of subcategory) subcategory page detail page. here code:
subcategory.html
<div> <ion-view view-title="subcategories"> <ion-list> <ion-item class="ionitems" ng-repeat="sublist in subcategories" href="#/app/playlists/{{sublist.id}}/details"> {{sublist.name}} <!--<a ng-click="godetails();">{{sublist.name}}<a/>--> </ion-item> </ion-list> </div>
detail page:
<ion-content> <h4>product details</h4> <ion-view view-title="playlists"> <ion-content ng-controller="playlistctrl"> <input type="button" ng-click="addtocart();" value="add cart" /> </ion-content>
add cart controller:
.controller('detailsctrl', function($scope){ var arr = []; $scope.addtocart = function () { arr.push("");
i need pass subcategory name subcategory page detail page , add cart controller. how can this?
you can send subcategory value url parameters
, kindly refer this link
from have create state
detail page
for example
.state('app.detail', { url: "/product/:productid", templateurl: 'detail.html', controller: 'detailsctrl' })
in detailsctrl
controller value i.e product id, can detail , show detail page
in controller
.controller('detailsctrl', function($scope,$stateparam){ var productid = $stateparam.productid; //now product id , detail , show on detail page });
your view code passing url parameters
<ion-view view-title="subcategories"> <ion-list> <ion-item class="ionitems" ng-repeat="sublist in subcategories"> <a ui-sref="detail({productid: sublist.productid})">{{sublist.name}}<a/> </ion-item> </ion-list>
Comments
Post a Comment