- First, you have to initialize your app by writing: 
    var myApp = angular.module("myApp", []);  

Read more here: https://docs.angularjs.org/api/ng/function/angular.module

- Second, create a controller named "myList" and add the controller's 
constructor function to the module using the.controller() method.
    myApp.controller("myList", function($scope){
        $scope.foods = ['Pizza','Pasta','Burger','Icecream','Pepsi']
}); 

https://docs.angularjs.org/guide/controller

Now your ng-repeat should work, but be sure to read through the docs, it 
can be really helpful. 


On Sunday, July 13, 2014 7:07:06 PM UTC+2, Ovidiu Mura wrote:
>
> Hi,
>
> I ran an example of 'ng-repeat' directive and it is not working. I spent a 
> lot of time on figuring what it is missing and I did not succeed. Please 
> help if you have the solution.
>
> The code of file 'myexample.jsp':
>
>
> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <!DOCTYPE html>
> <html>
> <head>
>     <script src="
> https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js
> "></script>
> </head>
>
> <body ng-app="myapp">
>
> <script>
>     var myList = function($scope){
>         $scope.foods = ['Pizza','Pasta','Burger','Icecream','Pepsi'];
>     };
> </script>
>
> <div ng-controller="myList" ng-model="foods">
>     <ul>
>         <li ng-repeat="food in foods">{{food}}</li>
>     </ul>
> </div>
>
> </body>
> </html>
>
> Thank you!
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to