I am struggling with ng-options, as I have created a dropdown from an array defined in my controller. Below is my HTML code:
<div ng-app>
<div ng-controller="testCtrl">
<select multiple="multiple" ng-model="first" ng-options="c.name for c in listObj">
</select>
<select multiple="multiple" ng-model="second">
</select>
<hr/>
{{first}}
</div>
</div>
Here is the corresponding JavaScript code:
function testCtrl($scope) {
$scope.listObj = [{name: "x", content: [1,2,3]},
{name: "y", content: [4,5,6]}];
}
You can view the working jsFiddle here:
http://jsfiddle.net/zono/rkBUL/10/
My goal is to have the right select box populated with the corresponding content property when a user selects an element from the left select box. For example:
If a user selects "x" from the left box, the right box should display 1,2,3. If "y" is added to the left box, it should display 1,2,3,4,5,6. If "x" is deselected, it should display 4,5,6.
Thank you in advance.