javascript - Angular : ng-repeat not working -


here code , take w3school.

<!doctype html> <html> <head> <meta charset="iso-8859-1"> <script type="text/javascript" src="./angular.min.js"></script> <script>     var app = angular.module('myapp', []);     app.controller('myctrl', function($scope) {         $scope.firstname = "sparsh";         $scope.lastname = "khandelwal";     }); </script> <title>home page</title> </head> <body>     <div ng-app="myapp" ng-init="name='sparsh'">         <div ng-controller="myctrl">{{firstname}}</div>         <p>             name : <input type="text" ng-model="name">         </p>         <h1>hello {{name}}</h1>     </div>      <div ng-app="" ng-init="names=['jani','hege','kai']">         <ul>             <li ng-repeat="x in names">{{x}}</li>         </ul>     </div> </body> </html> 

ng-repeat in second block not working.

here output on browser enter image description here

please me out

angular bootstraps first found application on page, i.e. first container ng-app attribute. second 1 put, ng-app="" ignored. although, manually bootstrap second 1 angular.bootstrap method, in case makes more sense wrap entire body same app , remove second ngapp directive:

<body ng-app="myapp">     <div  ng-init="name='sparsh'">         <div ng-controller="myctrl">{{firstname}}</div>         <p>             name :             <input type="text" ng-model="name" />         </p>         <h1>hello {{name}}</h1>     </div>     <div  ng-init="names=['jani','hege','kai']">         <ul>             <li ng-repeat="x in names">{{x}}</li>         </ul>     </div> </body> 

demo: http://plnkr.co/edit/uxtgewoaru82wpeovuoz?p=preview


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -