angularjs - Angular JS table with ng-repeat and radio buttons -
i trying make table using ng-repeat has radio button selector @ start of each row. table looks this:
<table> <tbody> <tr ng-repeat="model in modellist"> <td> <input type="radio" ng-model="model.select"></input> </td> <td>{{ model.ndpname }}</td> <td>{{ model.oem }}</td> <td>{{ model.version }}</td> <td>{{ model.dateadded }}</td> <td>{{ model.validuntil }}</td> </tr> </tbody> </table>
the ng-repeat taking modellist looks like:
$scope.modellist = [ { select: false, ndpname: "ndp1", oem: "choam inc.", version: "01", dateadded: "jan 1, 2013", validuntil: "jan 1, 2014", }, { select: false, ndpname: "ndp2", oem: "tyrell corp.", version: "01", dateadded: "jan 1, 2014", validuntil: "jan 1, 2015", }, { select: false, ndpname: "ndp3", oem: "stark industries", version: "01", dateadded: "jan 1, 2015", validuntil: "jan 1, 2016", }, { select: false, ndpname: "ndp4", oem: "monsters inc.", version: "01", dateadded: "jan 1, 2016", validuntil: "jan 1, 2017", }, { select: false, ndpname: "ndp5", oem: "acme corp", version: "01", dateadded: "jan 1, 2017", validuntil: "jan 1, 2018", } ];
the problem running radio buttons not behaving radio buttons. each in separate scope , therefore allow multiple rows in table selected. how can fix this?
you need set name
propertyfor radio buttons grouped together.
<input type="radio" name="groupname" ng-model="model.select" />
Comments
Post a Comment