0

I get this error:

Uncaught ReferenceError: MainCtrl is not defined, Argument 'MainCtrl' is not a function, got undefined

In plnkr it works okey but in my project not.

Any ideas? http://plnkr.co/edit/rPY6phUgtqavrEDUzhaH?p=preview

I have this in layout:

 <li ng-click="changeActiveMenu('Settings');"><a href="../Account/#/PersonalInfo">@Translate("MY_ACCOUNT")</a></li>
None
  • 6,894
  • 20
  • 72
  • 144

2 Answers2

2

Seems like you did not included your MainCtrl in index.html file like this

<script src="scripts/controllers/main.js"></script>
Muhammad Suleman
  • 2,718
  • 2
  • 23
  • 31
0

It is already answered here. In angular 1.3.x versions, you need to register the controller using module.controller syntax. Like

angular.module('plunker', []).controller('MainCtrl', ['$scope', 'ActivityService', function ($scope, activityService) { 

//Code

}])

Possibly there may be another reason. You're angular script is not loading on the dom. Please use

<script data-require="angular.js@1.3.x" src="//code.angularjs.org/1.3.16/angular.js" data-semver="1.3.16"></script> 

OR

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.16/angular.js"></script>

Without any http or https protocol.

Community
  • 1
  • 1
Vineet
  • 4,279
  • 3
  • 19
  • 42
  • Its not because of script because other stuff works fine its just when i use like this var MainCtrl = function() .... then error disappear but then highlighting menu is not working – None Jun 24 '15 at 07:45
  • Uncaught ReferenceError: MainCtrl is not defined(anonymous function) @ Config.js:16 angular.js:11607 Error: [ng:areq] Argument 'MainCtrl' is not a function, got undefined that is what i get in console – None Jun 24 '15 at 07:54
  • Check http://stackoverflow.com/questions/19719540/angularjs-jade-error-argument-mycontroller-is-not-a-function-got-undefined – Vineet Jun 24 '15 at 07:57