i wrote code
<label><input ng-model="filter['category']['auto']" value="auto" type="checkbox" name="category">auto</label> <label><input ng-model="filter['category']['music']" value="music" type="checkbox" name="category">music</label> in controller
$scope.filter = {}; and filter content filer. every thing working fine. want use radio instead of checkbox allow selection of 1 category. tried code
<label><input ng-model="filter['category'][type]" value="auto" type="radio" name="category" ng-change="type='auto'>auto</label> <label><input ng-model="filter['category'][type]" value="music" type="radio" name="category" ng-change="type='music'">music</label> but it's not working.
to use radio buttons ngmodel should same both inputs. there no need ngchange.
<label><input ng-model="filter['category']" value="auto" type="radio" name="category">auto</label> <label><input ng-model="filter['category']" value="music" type="radio" name="category">music</label> with filter object looks like
{ category: 'auto' } or
{ category: 'music' } with original code you'd end with
{ category: { auto: 'auto', music: 'music' } assuming category object. if not getting error.
Comments
Post a Comment