0

I started to learn angularJs (just in the beginning). I opened a new project in intelliJ (Static Web).

The code:

<!DOCTYPE html>
<html data-ng-app="">
<head lang="en">
    <meta charset="UTF-8">
    <title>Using Angularjs Directive and Data Binding</title>
</head>
<body>
<div ng-controller="SimpleController">
Name:
<br />
    <input type="text" ng-model="name"/>
</br>
<ul>
    <li ng-repeat="cust in customers | filter:name | order">{{ cust.name}}-{{cust.city}}</li>
</ul>
</div>
<script src="Scripts/angular.min.js"></script>
<script>
    function SimpleController($scopecust){
        $scopecust.customers= [
            {name:'John Smith', city:'Barca'},{name:'John Snow', city:'winterfull'},{name:'John Do', city:'milan'}
        ];
    }
</script>
</body>
</html>

For some reason i guess the controller is not bind .. all I see in the web page is Name with input field

Sarit Rotshild
  • 391
  • 3
  • 5
  • 21

1 Answers1

0

Because you haven't SimpleControllerin your Js At first you need define a module, after that define the controller, like below:

var app=angular.module('myModule',[])
app.controller('simpleController',function($scope){
             $scope.customers=  [
              {name:'John Smith', city:'Barca'},  {name:'John Snow',  city:'winterfull'},{name:'John Do', city:'milan'}
             ];
});

Now put the name of module in <html> like:

<html ng-app="myModule">
Kayvan Salimi
  • 335
  • 2
  • 13