I want to filter the details based on id which is commonly presented in two json files. How to do that ?
HTML:
<body ng-controller="FruitCtrl as fctrl">
<div class="col-xs-3">
<h4>Categories</h4>
<div class="list-group">
<a href="#" class="list-group-item" ng-repeat="x in categories">{{ x.category }}</a>
</div>
</div>
<div class="col-xs-9">
<h3>Details</h3>
<div class="panel panel-default" ng-repeat="info in fruitdetails">
<div class="panel-body">
<h5>{{info.name}}</h5>
<p>{{info.detail}}</p>
</div>
</div>
</div>
</body>
APP.JS
var app = angular.module('app', []);
app.controller('FruitCtrl', function($scope,$http) {
$http.get('category_json.json').success(function(data) {
$scope.categories=data;
});
$http.get('details.json').success(function(data) {
$scope.fruitdetails=data;
});
});
category_json
[
{"category": "All Category","cid":""},
{"category": "fruit","cid":"1"},
{"category": "nut","cid":"2"},
{"category": "Vegetable","cid":"3"}
]
detail.json
[
{"name": "apple","cid":"1","detail":"red in color"},
{"name": "carrot","cid":"3","detail":"good for eyes"},
{"name": "orange","cid":"1","detail":"orange in color"},
{"name": "almond","cid":"2","detail": "costly!!!"},
{"name": "banana","cid":"1","detail": "yellow in color"},
{"name": "beetroot","cid":"3","detail": "good for blood"},
]