Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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"]}
             ];
     });

Jsfiddle Demo

share|improve this question
1  
Where does 1022101 come from? You really want to hard-code that ID in the template? What are you really trying to achieve? – JB Nizet Nov 13 at 7:22

2 Answers 2

you can use | filter:{id:1022101} to filter fo the id

jsfiddle

share|improve this answer

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.