1

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

BundleTable.EnableOptimizations = true;

我有未捕获的错误。 http://errors.angularjs.org/1.3.15/$injector/modulerr?p0 _

在此处输入图像描述

控制器.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 一个一个地捆绑到这个中。如果工作正常,像这样更改下一个 js,我找到了问题行。希望以上详细信息将有助于在 js 中找到问题行

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

0 回答 0