6
Answers

i am new to angularjs...can anyone help me?

karthi keyan

karthi keyan

8y
1.4k
1
<!DOCTYPE html>
<html data-ng-app="">
<head>
<title>Using AngularJS Directives and Data Binding</title>
</head>
<body>
<div data-ng-controller="Simple">
Name:
<br />
<input type="text" data-ng-model="name" />
<br />
<ul>
<li data-ng-repeat="cust in customers | filter:name | orderBy:'city'">
{{cust.name}} - {{cust.city}}
</li>
</ul>
</div>
<script src="Scripts/angular.min.js"></script>
<script>
function Simple($scope){
$scope.customers = [
{ name : 'paul', city : 'mumbai' },
{ name : 'kicha', city : 'africa' },
{ name : 'ram', city : 'nigeria' }
];
}
</script>
</body>
</html>
Error:
angular.min.js:495 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?p0=Simple&p1=not%20a%20function%2C%20got%20undefined
at Error (native)
at http://localhost:5540/Scripts/angular.min.js:7:499
at sb (http://localhost:5540/Scripts/angular.min.js:70:27)
at Pa (http://localhost:5540/Scripts/angular.min.js:70:136)
at http://localhost:5540/Scripts/angular.min.js:365:237
at ag (http://localhost:5540/Scripts/angular.min.js:283:239)
at p (http://localhost:5540/Scripts/angular.min.js:263:274)
at g (http://localhost:5540/Scripts/angular.min.js:233:403)
at g (http://localhost:5540/Scripts/angular.min.js:233:428)
at g (http://localhost:5540/Scripts/angular.min.js:233:428)(anonymous function) @ angular.min.js:495
 
 
Answers (6)
1
Rajeev Punhani

Rajeev Punhani

348 4.7k 1.6m 8y

Hi Karthi,


Please check the below solution.

  1. <!DOCTYPEhtml>
  2. <html>
  3. <head>
  4. <title>UsingAngularJSDirectivesandDataBinding</title>
  5. </head>
  6. <body>
  7. <divdata-ng-app="myapp"data-ng-controller="Simple">
  8. Name:
  9. <br/>
  10. <inputtype="text"data-ng-model="name"/>
  11. <br/>
  12. <ul>
  13. <lidata-ng-repeat="custincustomers|filter:name|orderBy:'city'">
  14. {{cust.name}}-{{cust.city}}
  15. </li>
  16. </ul>
  17. </div>
  18. <scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
  19. <script>
  20. varapp=angular.module('myapp',[]);
  21. app.controller('Simple',functionSimple($scope){
  22. $scope.customers=[
  23. {name:'paul',city:'mumbai'},
  24. {name:'kicha',city:'africa'},
  25. {name:'ram',city:'nigeria'}
  26. ];
  27. });
  28. </script>
  29. </body>
  30. </html>

If the above solution is helpful then,accept the answer.
Accepted
1
Rajeesh Menoth

Rajeesh Menoth

66 27.1k 2.7m 8y
Hi,
 
Add data-ng-app in div tag and give one name for ng-app.
 
Demo : https://jsfiddle.net/rajeeshmenoth/ea94qhwm/
1
Midhun Tp

Midhun Tp

144 13.2k 1.5m 8y
Hi,
Try like below -
<div data-ng-controller="Simple" ng-app="myApp">
Name:
<br />
<input type="text" data-ng-model="name" />
<br />
<ul>
<li data-ng-repeat="cust in customers | filter:name | orderBy:'city'">
{{cust.name +' - '+ cust.city}}
</li>
</ul>
</div>
<script src="Scripts/angular.min.js"></script> 
<script>
angular.module('myApp', []).controller('Simple', function($scope) {
$scope.customers = [
{ name : 'paul', city : 'mumbai' },
{ name : 'kicha', city : 'africa' },
{ name : 'ram', city : 'nigeria' }
];
});
</script>
0
Bikesh Srivastava

Bikesh Srivastava

78 23.9k 3.6m 8y
If you are beginner visit my blog to learn angularjs step by step.
https://bikeshsrivastava.blogspot.in/search/label/AngularJs
0
Vinay Singh

Vinay Singh

297 6.3k 961.6k 8y
But what the error your are getting and what u r tying to do
0
Vinay Singh

Vinay Singh

297 6.3k 961.6k 8y
Hi
What the error you are getting