angularjs + yeoman + ng-switch + build:minify - >断言

时间:2013-01-09 07:27:27

标签: angularjs yeoman

我在angularjs中使用ng-switch在页面中包含动态内容,具体取决于url。我正在和自耕农管理我的项目。以下是动态内容生成的代码:

HTML:

<div class="div-content bgcontent" id="content">
  <span ng-switch on="renderPath[0]">
    <div ng-switch-when="home" ng-include="'partials/home.html'"></div>
    <div ng-switch-when="gallery" ng-include="'partials/gallery.html'"></div>
  </span>
</div>

控制器:

$scope.renderPath = $location.path().split('/');
// remove first entry because it's empty string
$scope.renderPath.shift();

当使用'yeoman服务器'运行时,这非常有效。但是,如果我使用'yeoman build:minify'构建,那么之后它就不再起作用了。它打了一个断言:

at assertArg (http://host:8888/scripts/vendor/d10639ae.angular.js:973:11)
at Object.ngDirective.compile (http://host:8888/scripts/vendor/d10639ae.angular.js:13474:5)
at applyDirectivesToNode (http://host:8888/scripts/vendor/d10639ae.angular.js:4047:32)
at compileNodes (http://host:8888/scripts/vendor/d10639ae.angular.js:3794:14)
at compileNodes (http://host:8888/scripts/vendor/d10639ae.angular.js:3799:14)
at compile (http://host:8888/scripts/vendor/d10639ae.angular.js:3739:29)
at update (http://host:8888/scripts/vendor/d10639ae.angular.js:13685:22)
at $get.Scope.$broadcast.next (http://host:8888/scripts/vendor/d10639ae.angular.js:8002:24)
at Array.forEach (native)
at forEach (http://host:8888/scripts/vendor/d10639ae.angular.js:110:11) <!-- ngSwitchWhen: home -->

有人知道如何解决这个问题吗?或者我需要调试它的位置?

1 个答案:

答案 0 :(得分:0)

如果您在脚本中使用依赖注入,请确保使用此处所述的minify-proof语法:http://docs.angularjs.org/guide/di