AngularJS与.NET MVC捆绑缩小错误

Ken*_*Ard 4 asp.net-mvc bundle angularjs

我一直在.NET MVC网站内开发一个大型AngularJS应用程序.如果使用Bundle Optimiazation功能,它是否会成功地进行测试,我已经走了很久没有测试?

BundleTable.EnableOptimizations = True
Run Code Online (Sandbox Code Playgroud)

当然,它失败了.我一直在玩Order I捆绑我的脚本,并确保我使用字符串文字作为我的控制器名称(我不是,这是我需要做的很多重新考虑因素).

但是如果没有角度"Unknown Provider"错误,我无法将我的Core Scripts送到Minifiy.

这是确切的错误:未捕获错误:[$ injector:modulerr] [ http://errors.angularjs.org/1.3.14/ $ injector/modulerr?p0 = ppAccount&p1 =错误... redScripts%3Fv%3DknV3wkCOg32ajaw4GwiRSrTXdo8Ue7MRIn65CPYa1b81%3A1%3A379851 )] 1

这是我的捆绑配置失败:

            bundles.Add(new ScriptBundle("~/bundles/PilotPartnerRequiredScripts")
      .Include(
          "~/UI/js/jquery/jquery-2.1.3.js",
          "~/UI/js/plugins/jquery-ui/jquery-ui.js",
          "~/UI/js/bootstrap/bootstrap.js",
          "~/UI/js/plugins/pace/pace.min.js",
          "~/UI/js/plugins/slimscroll/jquery.slimscroll.js",
          "~/UI/js/inspinia.js",
          "~/UI/js/angular/angular.js",
          "~/UI/js/ui-router/angular-ui-router.js",
          "~/UI/js/bootstrap/ui-bootstrap-tpls-0.12.1.js",
          "~/UI/js/angular/angular-resource.js",
          "~/UI/js/angular/angular-sanitize.js",
          "~/UI/js/angular/angular-route.js",
          "~/UI/js/plugins/switchery/switchery.js",
           "~/UI/js/plugins/angular-ui-switch/angular-ui-switch.js",
           "~/UI/js/plugins/angularLocalStorage/angular-local-storage.js",
           "~/UI/js/plugins/ngDialog/ngDialog.js",
           "~/Scripts/ngTags/ng-tags-input.js",
           "~/Scripts/uiSortable/sortable.js",
           "~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
           "~/Scripts/xeditable/xeditable.js"
Run Code Online (Sandbox Code Playgroud)

对于我的生活,我无法弄清楚哪个依赖关系没有得到解决.我觉得如果我可以将其缩小到特定的依赖关系,我知道我可以解决这个问题.

有没有办法找到导致问题的特定模块?

有关如何使这项工作的任何建议?

谢谢您的帮助.

Pan*_*kar 6

你应该总是遵循严格的di注入依赖(数组表示法)

Angualar Doc提到,在做缩小时,请遵循严格的DI,否则它可能会打破你的app

如:(代码)

angular.module('myModule', [])
.factory('serviceId', ['depService', function(depService) {
  // ...
}])
.directive('directiveName', ['depService', function(depService) {
  // ...
}])
.filter('filterName', ['depService', function(depService) {
  // ...
}]);
Run Code Online (Sandbox Code Playgroud)

在上面的代码片段中,我遵循了DI的内联数组符号,它已被应用于各种角度分量,只是为了演示它.您应该确保在注入依赖项的任何地方都遵循它.

  • 做了一些挖掘.就是这样.我发现我的App.config没有使用strict-DI,这导致了问题.这是我设置$ routeProvider的地方. (2认同)