假设我有两个列表,它们都依赖于相同的 JSON 数据。例如:
myApp.controller('MainCtrl', function($scope) {
$scope.print = {};
$scope.styles = [
{ style: 0, full:10, cut: '321' },
{ style: 1, full:11, cut: '432' },
{ style: 2, full:12, cut: '543' }
];
然后是两个列表:
<li class="listOne" ng-repeat="style in styles" item="style" ng-click="print.styleValue = style.full">
<li class="listTwo" ng-repeat="style in styles" item="style" ng-click="print.styleValue = style.full">
我想打印每个列表的选定值,而不进行第二个选择(在第一个选择之后),从而更改选定的值。这是{{从ListOne中选择“剪切”}} {{从ListTwo中选择“剪切”值}}。
{{ print.styleValue }} {{ print.styleValue }}
可能这需要两个 Controller ,或另一个 $scope,例如 $scope.styles2,并复制 JSON 数据。不过,我想避免重复 JSON 数据,所以如果有一种方法那就太棒了! 谢谢。
最佳答案
您为每个分配的 ng click 变量只需唯一,将其更改为 print.styleValue2
关于javascript - AngularJS:从相同数据中选择多个列表选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38919155/