AngularJS error: 'argument 'FirstCtrl' is not a function, got undefined'

前端 未结 16 1128
时光取名叫无心
时光取名叫无心 2020-12-01 05:55

I noticed the same question was asked a few times here, I tried so solve it but nothing helps.

I\'m following this tutorial with the egghead videos.

But whe

相关标签:
16条回答
  • 2020-12-01 06:38

    This can happen if you have gulp misconfigured to add your angular app code more than once. In my case, this was in index.js, and it was adding it as part of the directory of js files (globbed in gulp) before and after my controller declarations. Once I added an exclusion for index.js not to be minified and injected the second time, my app began to work. Another tip if any of the solutions above don't address your problem.

    0 讨论(0)
  • 2020-12-01 06:39

    You must name your ng-app, giving your app a namespace; simply using ng-app is not enough.

    Instead of:

    <html ng-app>
    ...
    

    You will need something like this instead:

    <html ng-app="app">
    ...
    

    Then, like so:

    var app = angular.module("app", []).controller("ActionsController", function($scope){});
    
    0 讨论(0)
  • 2020-12-01 06:40

    I had two controllers with the same name defined in two different javascript files. Irritating that angular can't give a clearer error message indicating a namespace conflict.

    0 讨论(0)
  • 2020-12-01 06:43

    remove ng-app="" from

    <div ng-app="">
    

    and simply make it

    <div>
    
    0 讨论(0)
提交回复
热议问题