1

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

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 server”运行这些东西时,这非常有效。但是,如果我使用 '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 -->

有人知道如何解决这个问题吗?或者我需要在哪里调试它?

4

1 回答 1

0

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

于 2013-02-27T13:26:22.870 回答