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
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>
Comments
Post a Comment