I am using angularJS to filter my data, the filter options are radio buttons fetched from a JSON API, but it does not work though using the usual route. my plunk
HTML
<div class="category">
<div ng-repeat="category in categories">
<input type="radio" name="typefilter" id="{{category.title}}" ng-model="typefilter" value='{{category.title}}'>
<label for="{{category.title}}">{{category.title}}</label>
</div>
</div>
<div class="food" ng-repeat="food in foods | filter:typefilter">
<h4>{{food.name}}</h4>
<p ng-repeat="food in food.type">{{food}}</p>
</div>
Controller
app.factory('Categories', ['$resource',
function ($resource) {
return $resource('https://safe-depths-4702.herokuapp.com/api/categories/:categoryId', {
categoryId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
]).factory('Foods', ['$resource',
function ($resource) {
return $resource('https://safe-depths-4702.herokuapp.com/api/foods/:foodId', {
foodId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
]).controller('MainCtrl', function($scope,Categories,Foods) {
$scope.categories = Categories.query();
$scope.foods = Foods.query();
});
my plunk