我在 Angular JS 中有一个产品列表,当我单击某个项目的链接时,我想将该产品的索引发送到一个新页面,在该页面中获取该项目的所有详细信息(类别、价格等)项目索引。这些信息将取自已在 javascript 中定义的同一数组。你有什么建议吗?
<!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>