0

I have a returned array of objects in AngularJS and i want to display it in two rows. I have something like this:

{"name":something ,"value0":12455.847233333334, "value1": 9.887...}

I have tried something like this:

                      <div class="row">
                       <div class="col-md-6" ng-repeat = "item in items track by $index" ng-if="$index < 10">
                      {{item}}


                       </div>
                       <div class="col-md-6" ng-repeat = "item in items track by $index" ng-if="$index >= 10">
                      {{item}}
                       </div>   

                    </div>

But it does not have the intended outcome. I want it to be displayed like

name: something

value0: 12455.847233333334

value1: 9.887

...

2 Answers 2

1

You need to iterate on object keys. Like this :

<div class="col-md-6" ng-repeat = "(key, value) in data" ng-if="$index >= 10">
        {{key}}:{{value}}
 </div>  
Sign up to request clarification or add additional context in comments.

3 Comments

it still gets displayed the whole array. Something like this 0: {"name":something ,"value0":12455.847233333334, "value1": 9.887...}
Then you are not getting object in data, you are getting an array. So you need to take care for that. If you want to display first row data of array then -> (key, value) in data[0] in ng-repeat
Welcome, If it worked then you can accept the answer :P
0

you can bind the values like these

<div class="row">
    <div class="col-md-6" ng-repeat = "item in items track by $index" ng-if="$index < 10">
       name: {{item.name}}

       value0: {{item.value0}}

       value1: {{item.value1}}

 </div>

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.