Tuesday, February 16, 2016

ng-repeat

index.html

     <div ng-controller="controller as vm" class="col-md-6 col-md-offset-3">
            <h2>{{vm.name}}</h2>
            <table class="table table-responsive table-striped">
                <tr ng-repeat="trip in vm.trips">
                    <td>{{trip.name}}</td>
                    <td>{{trip.created | date:'shortDate'}}</td>
                    <td><a href="#" class="btn btn-sm btn-primary">Manage</a></td>
                </tr>
            </table>
        </div>

module

(function () {
    'use strict';

    angular.module('app', [
        // Angular modules
   

        // Custom modules

        // 3rd Party Modules
     
    ]);
})();

controller

(function () {
    'use strict';

    angular
        .module('app')
        .controller('controller', controller);

    //controller.$inject = [''];

    function controller() {
        /* jshint validthis:true */
        var vm = this;
        vm.name = "greg";
        vm.trips = [{
            name: "US trip",
            created: new Date()
        }, {
            name: "World trip",
            created: new Date()
        }];
       }
})();

No comments:

Post a Comment