0

Let's say I have two lists, that both depend on the same JSON data. For example:

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' }
  ];

And then the two lists:

<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">

And I would like to print the selected value of each list, without the second selection (which comes after the first), changing the selected value. This being {{ selected "cut" from ListOne}} {{ Selected "cut" of Value from ListTwo }}.

{{ print.styleValue }} {{ print.styleValue }} 

Possibly this needs two controllers, or another $scope, for example $scope.styles2, and duplicate the JSON data. I would like to avoid duplicating the JSON data though, so if there's a way that would be amazing! Thanks.

0

1 Answer 1

1

The ng click variable you assign to for each just needs to be unique change one to print.styleValue2

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but when I tried this it simply duplicated the selection on the later list. I'm actually trying it in Ionic, I have a codepen which I'll put later, can't on my mobile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.