0

I have List of objects as follow where I have objects nested inside object. I want to display information using ng-repeat but its not working.

<div ng-repeat="x in customer">

                      {{x.name}}


                </div>

AngularJs code

var myapp=angular.module('myapp',[]);
myapp.controller('MyController',['$scope',function($scope){
            $scope.val="this is test";
            $scope.customer=
                [1:{
                      name:{
                      firstname:"",
                      lastName:""
                    },
               address:{
                        city:"city",
                        country:"country",
                        zipCode:65775
            }
             },
          //other customer data
    ];

        });

for simple object list ng-repeat works well . I am not able to work with complex object where I am getting wrong?.

2 Answers 2

1

Do:

<div ng-repeat="x in customer">Hi, {{x.name.firstname}} {{x.name.lastname}}!</div>

If you just do

{{x.name}}

You won't actually output anything, or it will say [object Object] since the value will be [object Object] and not any of the properties inside the object.

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

Comments

1
 <div ng-repeat="x in customer">
                          <h3>{{x.name.firstname}} {{x.name.lastname}}<h3>
                          <p>{{x.address.city}} {{x.address.country}}</p>
   </div>

1 Comment

This will output another div with information for every property in the nested object.. EDIT: Now it's correct.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.