2016-01-25 31 views
0

我有一个MVC 5应用程序捆绑了我的角应用程式,例如例如:角捆绑/ MVC通过精缩无法加载主模块

var angular = new ScriptBundle("~/App") 
      .Include("~/App/app.js") 
      .IncludeDirectory("~/App", "*.js", true); 

     bundles.Add(angular);  

然后呈现它的头部,所有其他资源后加载,在这里:

(jquery, angular.min.js, other resources) 
@Scripts.Render("~/App") 

切换打开我的web.config的调试属性设置为false:

<compilation debug="false" targetFramework="4.5.2" /> 

主要模块我的角度应用程序不加载:

Error: [$injector:nomod] Module 'wdf' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

之前你链接我如何确保角度将缩小的形式加载,要知道我已经三重检查每一个工厂,控制器,服务[你的名字文档它],为AngularJS's documentation中列出的正确语法。我也减少了我的整个角申请下来到一个单独的文件和一行,以消除可能的其它注射错误:

(function() { 
'using strict';  

var app = angular.module('wdf', []); 

})(); 

我也一直在HTML表述为这样的应用:

<!DOCTYPE html> 
<html ng-app="wdf" ng-strict-di> 
... 

即使使用ng-strict-di,应用程序仍可以非常精细地运行。我一直在摔跤几个小时。每个线程我基本上可以挖告诉我,确保我已经宣布所有模块的依赖关系的权利,但我敢肯定,我已经考虑:

  1. ng-strict-di还没有抓到任何东西我应该有更好的编码
  2. 我三重检查每一个受诅咒的文件,以确保我已经按照最佳做法缩小
  3. 最后,应用程序甚至不工作这是最简单的形式

回答

0

儿子的...当然,对我发帖,我找到了问题。

我没有看开发工具,看看网站是否正确加载缩小文件。这是捆绑请求返回403。这里用一个样式包概述的解决方案的工作原理是一样的 MVC4 style bundle giving 403

总之,修复了这一变化:

FROMvar angular = new ScriptBundle("~/App")

TOvar angular = new ScriptBundle("~/wdf")

,然后改变它的HTML,以及:@Scripts.Render("~/wdf")

希望这有助于别人谁遇到了这个问题...