angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

templateUrl should support <script type=text/ng-template #321

Closed jasonkuhrt closed 11 years ago

jasonkuhrt commented 11 years ago

Maybe I am mistaken but ui-router does not appear to support templateUrl lookup for ng-template script tags. It seems like it should, in order to be a good citizen.

ksperling commented 11 years ago

This should already work, those script tags simply load the template into $templateCache, which $templateProvider uses already.

jeme commented 11 years ago

Did you by any chance place the templates outside the scope of "ng-app" ?... They have to be in the DOM hierarchy of that tag...

E.g: http://jsfiddle.net/fEbgM/30/

jasonkuhrt commented 11 years ago

Sorry for the noise on this, I checked the codebase later on and realized it ought to work. For some reason the <script type="text/ng-template" tags are not registering templates in $templateCache. Very odd, but not your problem.

Thanks

jasonkuhrt commented 11 years ago

@ksperling

When I remove ui.compat this works:

<div class="bitboard" ng-app="bitboardApp" ng-controller="BitboardController" ui-view>
  <script type="text/ng-template" id="foo.html">
    foobar
  </script>
  <ng-include src="'foo.html'"></ng-include>

But the above outputs nothing once I've included ui.router. I'm using angular 1.1.5.

Seems like a bug?

jasonkuhrt commented 11 years ago

Update:

If I depend on ui.router instead of ui.compat ng-template works but the .config block DI fails:

angular.module('bitboardApp', ['ui.mask', 'ui.router'])
.config(function($stateProvider){
})
...
Uncaught Error: Unknown provider: $stateProvider from bitboardApp 
timkindberg commented 11 years ago

If you are using 0.0.1 you need to use ui.state. We JUST changed the module name over to ui.router and it won't be in a release build until 0.0.2 which is coming soon. You can also do a manual build. See the Develop section of the main readme.

jasonkuhrt commented 11 years ago

@timothyswt Cool, so you recommend I go with 0.0.2? All the docs/guides are for 0.0.2 right?

jasonkuhrt commented 11 years ago

Oh @ksperling The problem was that I had my <script type="text/ng-template ... nested under ui-view. This isn't an obvious error in my opinion, maybe its worth a mention somewhere.

timkindberg commented 11 years ago

That or use 0.0.1 and add ui.state as your module dependency.

timkindberg commented 11 years ago

Yes the docs are all in 0.0.2 for the most part I think.

On Thu, Aug 15, 2013 at 7:46 PM, Tim Kindberg timkindberg@gmail.com wrote:

That or use 0.0.1 and add ui.state as your module dependency.

Thanks,

Tim Kindberg