angularjs - My ng-repeat does not work -


i have little problem when generated ng-repeat, there nothing going on in html.

does me settle problem?

var myapp = angular.module('myapp', []) .controller('myctrl', function($scope){     list = [];      $scope.generatealbum= function() {         return {             name : faker.name.firstname()                };     };      $scope.generate= function(count) {         count = count || 25;         list;         (var = 0; < count; i++) {             list.push($scope.generatealbum());         }         return list;     };      $scope.generate();  }); 

and here html :

<!doctype html> <html ng-app="myapp"> <head>     <title></title>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>     <script src="http://marak.com/faker.js/js/faker.js"></script>     <script src="js/app.js" type="text/javascript"></script> </head> <body> <main>     <section ng-controller="myctrl">         <ul ng-repeat="item in list">             <li>{{item.name}}</li>         </ul>     </section> </main>  </body> </html> 

and link example : http://plnkr.co/edit/cjm53o4ne8r929jijoer?p=preview

your list needs scope property. functions not

var myapp = angular.module('myapp', []) .controller('myctrl', function($scope){   var list = [];    function generatealbum() {         return {             name : faker.name.firstname()                };   }    function generate(count) {         count = count || 25;         (var = 0; < count; i++) {             list.push(generatealbum());         }         $scope.list = list;     }      generate(); }); 

http://plnkr.co/edit/ianwy9wtt5jyb9oijaqu?p=preview


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -