捆绑angularjs后MVC4不能正常抛出异常

时间:2016-02-06 15:05:27

标签: angularjs asp.net-mvc-4 model-view-controller asp.net-bundling

在我的MVC4应用程序中使用angularjs工作正常并且没有错误。如果我使用

捆绑js和css

BundleTable.EnableOptimizations = true;

我没有发现错误。  http://errors.angularjs.org/1.3.15/ $注射器/ modulerrδP0

enter image description here

Controller.js

App.controller('userController',
  ['$rootScope', '$scope', '$state', 'exDialog', '$stateParams', 'toaster', 'Upload', '$modal',
  function ($rootScope, $scope, $state, exDialog, $stateParams, toaster, Upload, $modal) {

//Logic here

}]);

解决方案

问题是我们在缩小时的问题。使用单个字符更改指令名称以进行缩小。

发布Js查找方法

public class NonMinifying : IBundleTransform
    {
        public void Process(BundleContext context, BundleResponse bundle)
        {
            if (bundle == null)
            {
                throw new ArgumentNullException("bundle");
            }

            //context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();
            foreach (var file in bundle.Files)
            {
                HttpContext.Current.Response.AddFileDependency(HttpContext.Current.Request.MapPath(file.IncludedVirtualPath));
            }

        }
    }

像下面的代码一样创建包并将你的js逐个捆绑到this.if工作正常改变下一个js 像这样我找到了问题。希望上面的细节将有助于在js中找到问题行

  bundles.Add(new Bundle("~/bundles/appScriptsnonmini", new NonMinifying())
              .IncludeDirectory("~/Scripts/app", "*.js")                     
                );

0 个答案:

没有答案