I am new to AngularJS and using plnkr.co to acquire how to utilize angular. I have having some difficulty registering a Controller this is stored in a separate .js from where the module is initialized. Tin can anybody tell me why the below does not piece of work?

index.html file

                  <!DOCTYPE html> <html ng-app="plunker">  <head>   <meta charset="utf-8" />   <title>AngularJS Plunker</championship>   <script>     document.write('<base of operations href="' + document.location + '" />');   </script>   <link rel="stylesheet" href="style.css" />   <script data-require="angular.js@1.4.10" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/one.iv.6/angular.min.js" information-semver="1.4.6"></script>   <script src="app.js"></script>   <script scr="mainCtrl.js"></script> </head>  <body ng-controller="MainCtrl">   <p>Hello {{name}}!</p> </trunk>  </html>                

app.js File

                  angular.module('plunker', []);                

mainCtrl.js File

                  angular.module('plunker')   .controller('MainCtrl', ['$telescopic', function($telescopic) {     $scope.proper noun = 'GitHub';   }]);                

For me, this produces an Argument 'MainCtrl' is not a function, got undefined.

asked Sep 29, 2015 at 22:ten

2

  • pretty easy to audit in network tab of dev tools to meet file isn't being loaded

    Sep 29, 2015 at 22:21

i Answer 1

Supersede

                  <script scr="mainCtrl.js"></script>                                  

with

                  <script src="mainCtrl.js"></script>                                  

Considering of the typo (scr instead of src), the source file holding MainCtrl is not loaded, therefore MainCtrl is undefined.

answered Sep 29, 2015 at 22:20

3

  • Do you have any link from the assist center well-nigh that?

    Sep 29, 2015 at 22:25

  • I am also dependent on intellisense these days :)

    Sep 29, 2015 at 22:26

  • Information technology's ane of the reasons listed under "close" voting push, but call up of it like this - would the answer exist of much assist to a future visitor? I don't think then, since the solution is barely related to the purported issue of the original question, and the OP can exist helped via comment.

    Sep 29, 2015 at 22:27

Not the answer you're looking for? Browse other questions tagged angularjs model-view-controller ng-controller or inquire your own question.