Reputation: 1
<a href="productview.html?sku" ng-click="retrive_click">
<div ng-repeat="product in products" class='custom-products'>
<div class='custom-products custom-products-image'>
<img src='{{product.image_url}}' />
</div>
<div class='custom-products custom-products-currency'>
<span>{{product.price}}</span>
</div>
</div>
</a>
On ng button click want to get id of sku to another page
Need your help
Upvotes: 0
Views: 36
Reputation: 22212
If you want to use your ID (in your case your sku) in another view you can do it using $routeProvider.
Here I show you an example on JSFiddle
HTML
<div ng-app="myapp">
<div ng-view></div>
<script type="text/ng-template" id="/list.html">
<h4>List</h4>
<a href="#/detail/1" class="btn">One</a>
<a href="#/detail/2" class="btn">Two</a>
<a href="#/detail/3" class="btn">Three</a>
</script>
<script type="text/ng-template" id="/detail.html">
<h4>Id from the other view is {{id}}</h4>
</script>
</div>
JS
var myapp = angular.module('myapp', []).config(function ($routeProvider) {
$routeProvider
.when('/list', {
templateUrl: '/list.html'
})
.when('/detail/:id/', {
templateUrl: '/detail.html',
controller: 'DetailCtrl'
})
.otherwise({
redirectTo: '/list'
});
});
myapp.controller('DetailCtrl', function ($scope, $routeParams) {
$scope.id = ($routeParams.id) ? parseInt($routeParams.id) : 0;
});
Upvotes: 1