ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

Grunt Dist Server won't load ng-templates, looks for views directly even though ngTemplates are generated. #151

Closed cartofrontdev closed 8 years ago

cartofrontdev commented 8 years ago

Hi Eric & everyone!

I spent 5+ hours and looked at the previous issues, but I can't seem to crack my issue. Hopefully you can provide some insight.

When I run my grunt serve:dist after I built, my app looks for the templates directly, even though my scripts has my generated templates included and my tmp folder has a fully created templateCache.js with all my views in js.

My chrome browser goes crazy looking for the first template in my initial state, i'm using ui-router for angular states. It won't load the first state template, nor will it load directly referenced templates. However in my regular grunt serve I have no errors. No console errors. Nothing. Every feature works fine.

I read previously to check all my formats, I can confirm that there are no ng-includes or templateUrl in my App.js which has an irregular format. But again all references work fine in my grunt serve version, just not my dist serve.

If I copy and past the views folder (I am using the yeoman generated format) into my dist, the templates come right up, but obviously I want my angular app to recognize my templates.

Last thing I changed my logic for one of my views trying to be fancy with the ngClass..

<div ng-class="toggleSideMenuNavView()" class="baseSideNav">
    <div ng-include=" 'views/Shared/_SideMenu.html' "></div> (<- spaces for distinction)
</div>

Let me know what additional information you may need and thank you to you and everyone in advance.

Dennis O.

cartofrontdev commented 8 years ago

Please close this non-issue. My IFEE statement was missing a semicolon. Thank you for this wonderful tool.

underscorebrody commented 8 years ago

haha whoops! i had started to think through what might be causing this, glad it was a relatively easy fix. :+1:

daniel-nalbach commented 8 years ago

@cartofrontdev - What is IFEE? I'm experiencing this same issue in an app.

underscorebrody commented 8 years ago

@daniel-nalbach I believe he means his immediately invoked function expression (IIFE).

daniel-nalbach commented 8 years ago

@underscorebrody - Thanks! His answer caused me to look at syntax around my issue. It turned out that my app folder name for the angular module was camelcase, but the module name itself was lowercase. In our build process, we use the module name as part of the new templateUrl path. That meant the view was declared in our route as templateUrl: xxXX/... but the build path was actually xxxx/, which explains why a static html file was being looked for outside of the templateCache.