Closed jasonkuhrt closed 11 years ago
This should already work, those script tags simply load the template into $templateCache, which $templateProvider uses already.
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...
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
@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?
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
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.
@timothyswt Cool, so you recommend I go with 0.0.2? All the docs/guides are for 0.0.2 right?
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.
That or use 0.0.1 and add ui.state as your module dependency.
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
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.