0
votes

I'm getting error with angular JS Error: [ng:areq] Argument 'MyController' is not a function, got undefined, when trying to use bundles. However when I explicity include the app in my html using script tags it works. Bundle Config.cs

 bundles.Add(new ScriptBundle("~/bundles/myweb")
    .IncludeDirectory("~/Scripts/myweb", "*.js")
    .IncludeDirectory("~/Scripts/myweb/Controllers", "*.js")   
    .Include("~/Scripts/myweb/Controllers/myController.js")
    .Include("~/Scripts/myweb/myweb.js"));

With this HTML does not work:

<script src="~/Scripts/angular.js"></script>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/myweb")

This HTML does work but I'm unsure why I have to explicitly include myApp.js since it is already included in the bundle (and when I view the bundle from F12 - Developer Tools on Google Chrome it does already include the expected code):

<script src="~/Scripts/angular.js"></script>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/myweb")
<script src="~/Scripts/myweb/myweb.js"></script>

Note the shown html is in the head of _Layout.cshtml. I'm using angularJS with MVC.

1

1 Answers

0
votes

Just figured out how to fix this.

I basically need to include the following code

<script src="~/Scripts/angular.js"></script>
@Scripts.Render("~/bundles/myweb")

in both the _Layout.cshtml and the index.cshtml (I only had it in Index.cshtml)