Reputation: 49
I am trying to cache $templatecache
as my html is coming from controller as string than I just put it in to cache using $templatecache
but when i am trying to include it in HTML using following statement than its showing me 404 not found error in console.
http://local.mydomain.com/myaccount/dqs.html 404 (Not found)
"<div id="dqs" ng-include="'dqs.html'" class="form__main" set-height></div>"
Angular code :
$templateCache.put('dqs.html', filteredFormHtml);
Upvotes: 1
Views: 378
Reputation: 202
As you are adding your template in html, you need to first cache that template by using $templateRequest service.
$templateRequest('/myaccount/dqs.html').then(function (filteredFormHtml) {
$templateCache.put('filteredFormHtml', filteredFormHtml);
});
Once the template is cached, you can use it anywhere in your template using ng-include
"<div id="dqs" ng-include="'dqs.html'" class="form__main" set-height></div>"
Below are the user links for better understanding on $tempalteCache Service
1) https://docs.angularjs.org/api/ng/service/$templateCache
2) https://thinkster.io/templatecache-tutorial
Upvotes: 1