0

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

1
  • 1
    Where does 1022101 come from? You really want to hard-code that ID in the template? What are you really trying to achieve? Commented Nov 13, 2015 at 7:22

2 Answers 2

1

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

jsfiddle

Sign up to request clarification or add additional context in comments.

Comments

0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.