0

http://plnkr.co/edit/KPMUOp16FAArgx1GsnEx?p=preview

Looking at the code, the first array of variables corresponds to a list of radio boxes. When you click on any of them, it creates a second radio box list. The radio boxes on the second list are created by filtering out a second array based on the first selection. Debug shows first selection. What I'm trying to do is display a variable that corresponds to a radio box that you select from the filtered list.

So you click "Apple", a radio box list of of "Red" and "Yellow" appears. If I was to click on Red, Debug2 should show red - variable from $scope.employees array.

Ideas?

3
  • Where is the checkbox? Debug seems to be doing the same thing as your requirement - why are you looking for Debug2? Commented Mar 27, 2014 at 15:38
  • If you click on "Apple" a set of check boxes appear. If I click on them, I want their variables to be passed to Debug2. Commented Mar 27, 2014 at 15:41
  • Please edit your question then with this information. It is not clear from the current question the problem that you face.. Commented Mar 27, 2014 at 15:43

2 Answers 2

2

Create in controller the model:

$scope.selectedSub =$scope.employees[0].value;   

After, add the model to radio-buttons:

<div ng-repeat="emploee in employees | filter:filterFunctions.forWorkspace(filtering.workspace_id)">
      <input type="radio" 
      value="{{emploee.value}}"
      ng-model="$parent.selectedSub"
      name="{{emploee.name}}">{{emploee.sub_text}}</input>

See Demo in Plunker

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

2 Comments

Hm. Is there a way to combine selectedSub and filtering under one model. The output in this case would be {"workspace_id": "A", "selectedSub": "red"}
I don't think so. Each item in ng-repeat directive has its own scope. So if you want to use one of elements out of loop, it should be object predefined in controller
1

Create a method in controller to set value for Debug2

$scope.Debug2val="";
  $scope.setDebug2val=function(val)
  {
    $scope.Debug2val=val;
  }

Then in HTML pass the radio button text to the above method on ng-click event.

Here is the JSFiddle

1 Comment

Good call on the ng-click!

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.