I have a list of products in Angular JS and when I click the link for a certain item I want to sent the index of that product to a new page where to get all the details for that item (category, price etc) base on the item index. The informations will be taken from the same array already defined in javascript. Do you have any sugestion?
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="productsCtrl">
<ul id="products">
<li ng-repeat="entry in entries">
<a href="#!{{$index}}">{{entry.title}}</a>
<span ng-click="removeItem($index)" style="cursor: pointer;"
>x</span
>
</li>
</ul>
</div>
<script>
angular
.module("myApp", [])
.controller("productsCtrl", function($scope) {
$scope.entries = [
{
title: "Laptop",
category: "Category01",
price: 233
},
{
title: "Phone",
category: "Category02",
price: 122
},
{
title: "Mouse",
category: "Category03",
price: 10
}
];
$scope.removeItem = function(index) {
$scope.entries.splice(index, 1);
};
});
</script>
</body>
</html>