ng-repeat

 

<DOCTYPE html>
<html>
    <head>
        <meta CHARSET="UTF-8">
        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    </head>
    <body ng-app="myApp" ng-controller="myCtrl">
        <h2>ng-repeat</h2>
        <fieldset>
            <legend>
                List
            </legend>
            <div ng-init='name = ["Shailesh", "Mahesh", "Shilpa"]'>
                <ul>
                    <li ng-repeat="x in name">{{x}}</li>
                </ul>
            </div>
        </fieldset>
        <fieldset>
            <legend>
                Table
            </legend>
            <div ng-init='months = ["Jan", "Feb", "Mar"]'>
                <table border="1">
                    <tr ng-repeat="x in months">
                        <td>{{x}}</td>
                    </tr>
                </table>
            </div>
        </fieldset>
        <fieldset>
            <legend>
                Select
            </legend>
            <div ng-init='cities = [{"id":"1", "value":"Mumbai"}, {"id":"2", "value":"Pune"}, {"id":"3", "value":"Nagpur"}]'>
                <select>
                    <option ng-repeat="x in cities" value="{{x.id}}">{{x.value}}</option>
                </select>
            </div>
        </fieldset>
    </body>
    <script>
                var app = angular.module("myApp", []);
                app.controller("myCtrl", function($scope) {

                });
    </script>
</html>

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *