Reputation: 18864
Is there a way to include html templates in AngularJS modules without putting them as strings into js code into the templateCache?
Upvotes: 1
Views: 1461
Reputation: 1631
If you want to include one html in another, you can use ng-include directive of angularjs.
I have used this like below:
<div ng-include src = "'partials/myModule/myHtml.html'"></div>
Upvotes: 1
Reputation: 1700
The way we've accomplished this is to write our html templates as standalone html files, then use a grunt task to crunch them into strings (handles all the escaping etc) and inject them into the template cache. best of both worlds, as the developers can work on individual HTML files all under source control, but we drastically reduce roundtrips to the server to pull the templates down to the app at runtime. (At the cost of up-front loading)
Upvotes: 2