Error: Argument is not a function, got undefined

前端 未结 17 1894
不思量自难忘°
不思量自难忘° 2020-12-07 19:35

Using AngularJS with Scala Play, I\'m getting this error.

Error: Argument \'MainCtrl\' is not a function, got undefined

I\'m try

17条回答
  •  甜味超标
    2020-12-07 20:24

    Уmed's second point was my pitfall but just for the record, maybe it's helping someone somewhere:

    I had the same problem and just before I went nuts I discovered that I had forgotten to include my controller script.

    As my app is based on ASP.Net MVC I decided to keep myself sane by inserting the following snippet in my App_Start/BundleConfig.cs

    bundles.Add(new ScriptBundle("~/app").Include(
                    "~/app/app.js",
                    "~/app/controllers/*.js",
                    "~/app/services/*.js" ));
    

    and in Layout.cshtml

    
    ...
       @Scripts.Render("~/app")
    ...
    
    

    Now I won't have to think about including the files manually ever again. In hindsight I really should have done this when setting up the project...

提交回复
热议问题