AngularJS ng-repeat -5

In this example, using ng-repeat with nested loops

by Varun Sukheja

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script>
<div ng-controller='MyController' ng-app="myApp">
    <h4>Customer data </h4>
    <ul>
        <li ng-repeat='customer in Customers'>
            Name: {{customer.Name}}
            <br> Country: {{customer.Country}}
            <br>
            <ol>
                <li ng-repeat='order in customer.Orders'>
                    OrderId: {{order.OrderId}}, Freight: {{order.Freight}}, ShipCountry: {{order.ShipCountry}}
                </li>
            </ol>
        </li>
    </ul>
</div>

JavaScript

var app = angular.module('myApp', []);
app.controller('MyController', ['$scope', '$interval', function($scope, $interval) {
    $scope.title = 'Hello world';
    $scope.Customers = [{
        CustomerId: 1,
        Name: "John Hammond",
        Country: "United States",
        Orders: [{
            OrderId: 10248,
            Freight: 32.38,
            ShipCountry: 'France'
        }, {
            OrderId: 10249,
            Freight: 12.43,
            ShipCountry: 'Japan'
        }, {
            OrderId: 10250,
            Freight: 66.35,
            ShipCountry: 'Russia'
        }]
    }, {
        CustomerId: 2,
        Name: "Mudassar Khan",
        Country: "India",
        Orders: [{
            OrderId: 10266,
            Freight: 77.0,
            ShipCountry: 'Argentina'
        }, {
            OrderId: 10267,
            Freight: 101.12,
            ShipCountry: 'Australia'
        }, {
            OrderId: 10268,
            Freight: 11.61,
            ShipCountry: 'Germany'
        }]
    }, {
        CustomerId: 3,
        Name: "Suzanne Mathews",
        Country: "France",
        Orders: [{
            OrderId: 10250,
            Freight: 65.83,
            ShipCountry: 'Brazil'
        }]
    }, {
        CustomerId: 4,
        Name: "Robert Schidner",
        Country: "Russia",
        Orders: [{
            OrderId: 10233,
            Freight: 89.11,
            ShipCountry: 'Belgium'
        }, {
            OrderId: 10234,
            Freight: 51.30,
            ShipCountry: 'Canada'
        }, {
            OrderId: 10235,
            Freight: 46.11,
            ShipCountry: 'Austria'
        }]
    }];

}]);