Reputation: 19
I want to make multidimensional JSON array. So that when i filter the id i whould get data of the respective id:
for egs: ID 1022101 the view should be
<li>x</li>
<li>y</li>
<li>z</li>
<div ng-app="myapp">
<div ng-controller="w">
<ul ng-repeat="x in data | filter:1022101 ">
<li>{{x.file}}</li>
</ul>
</div>
</div>
controller:
var app = angular.module('myapp',[]);
app.controller('w',function($scope){
$scope.data = [
{"id":"1022101","file":["x","y","z"]},
{"id":"1022102","file":["xa","sy","fz"]}
];
});
Upvotes: 0
Views: 57
Reputation: 1289
If I understand correctly what you are trying to do then you can use something lik this:
<ul ng-repeat="(id, file) in data | filter:id:1022101 ">
<li>{{file.x}}</li>
<li>{{file.y}}</li>
</ul>
I am not 100% sure I wrote the filter correctly, but you have your value in the id so you can adjust the filter as you need.
If your file is an Json array, you can make another ng-repeat inside your ng-repeat like
<ul ng-repeat="(id, file) in data | filter:id:1022101 ">
<li ng-repeat="xFile in file">{{xFile}}</li>
</ul>
Upvotes: 0