I am facing some problem with dynamic ng-model values in my angular page. Here is my sample JSON.
mytabs = [
{
name : "tab1",
values : [
{value:"value1"},
{value:"value2"},
{value:"value3"},
{value:"value4"}
]
},
{
name : "tab2",
values : [
{value:"value1"},
{value:"value2"},
{value:"value3"},
{value:"value4"}
]
}
]
What I want to do from this josn is, creating a view in my page such that, It will contain tab1
and tab2
as headings of page and the respective value
as a checkbox
. The user will have the selectivity to select his option. On submit I want to get the options he selected. I want to know something like value1,value3 (frome tab1)
, value1,value2(from tab2)
are selected, in my controller. How can I do this?
Here is my sample approach.
<div ng-repeat="tab in mytabs">
<h1>{{tab.name}}</h1>
<div ng-repeat="val in tab.values">
<input type="checkbox" ng-model="val.value"/>
</div>
</div>
<input type="button" value="submit" ng-click="checkValues(val)"
Please help me,
Thank you