0

This doesn't work:

  <div ng-app ng-controller="MyCtrl">
     <input type="text" ng-model="sometext" />
     <p>{{sometext}}</p>
     <ul ng-repeat="item in somelist">
         <li>{{item}}</li>
     </ul>
 </div>
<script src="scripts/angular.js"></script>
<script src="scripts/app/app.js"></script>

and if I reference angular from CDN it is ok?

I started with Empty Web project in VisualStudio and added angular using nugetenter image description here

This is error from angular

Error: [ng:areq] Argument 'MyCtrl' is not a function, got undefined
http://errors.angularjs.org/1.3.0/ng/areq?p0=MyCtrl&p1=not%20a%20function%2C%20got%20undefined
at http://localhost:60732/scripts/angular.js:80:12

Edit1 Controller code:

var MyCtrl = function($scope) {
$scope.somelist = ['1', '2', '3'];

return true;

};

This Works

<div ng-app ng-controller="MyCtrl">
     <input type="text" ng-model="sometext" />
     <p>{{sometext}}</p>
     <ul ng-repeat="item in somelist">
         <li>{{item}}</li>
     </ul>
 </div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="scripts/app/app.js"></script>
malibeg
  • 2,237
  • 2
  • 17
  • 21
  • Post your code. Error means that you messed with the way you wrote something. Post contents of app.js. – dfsq Oct 30 '14 at 10:23
  • Added controller code. – malibeg Oct 30 '14 at 10:26
  • 1
    Have a look at this question relating to controllers and global scope in 1.3 (your cdn ref is 1.0.7) as it may apply in your case: http://stackoverflow.com/questions/26646941/getting-an-error-when-using-ng-controller-in-angularjs-ver-1-3-0 – Gruff Bunny Oct 30 '14 at 10:49
  • 2
    You can't use simple global function without a module with Angular 1.3. – dfsq Oct 30 '14 at 10:51

0 Answers0