1

I am using an ng-switch in angularjs to have dynamic content in my page, dependent on the url. And I am managing my project with yeoman. Here is the code of the dynamic content generation:

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>

controller:

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

This works perfectly well when running the stuff with 'yeoman server'. But if I build with 'yeoman build:minify', it doesn't work anymore afterwards. It hits an assertion:

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 -->

Does someone know how to fix this? Or where I need to look to debug it?

David Graf
  • 1,152
  • 2
  • 13
  • 24
  • Does the build:minify somehow change the name of 'partials/home.html'? – asgoth Jan 09 '13 at 09:39
  • No, it doesn't. Names of html files in partials are still the same. – David Graf Jan 09 '13 at 15:40
  • Additional information: build and build:text works properly, build:default fails with the error explained here: https://github.com/yeoman/yeoman/issues/288, build:buildkit and build:basiscs fails with the assertion explained above. – David Graf Jan 10 '13 at 09:04
  • @DavidGraf did you ever figure this out? I'm running into the same problem. – binarygiant Jun 23 '14 at 15:57
  • @binarygiant At the time I asked this question, I didn't understand angular well. You should use ngRoute and views to do this (https://docs.angularjs.org/api/ngRoute/service/$route). – David Graf Jun 25 '14 at 04:25

1 Answers1

0

If you are using dependency-injection within your scripts, make sure to use the minify-proof syntax as described here: http://docs.angularjs.org/guide/di

thumbsup
  • 431
  • 5
  • 11