How to reload a template in ng-include angularjs

I want to reload a template that I have included in the page using ng-include

<div ng-include="exercise_tpl.url"></div>

      

I can do this by loading an empty template and loading the previous template again like this

$scope.exercise_tpl.url = 'partials/blank.html';
        $('body').trigger('click');
        setTimeout(function() {
            $scope.exercise_tpl.url = 'partials/memory.html';
            $('body').trigger('click');
        }, 300);

      

I want to know the correct way to reload a template in Angularjs. Please, help.

+3


source to share


1 answer


Templates are cached if the user has no permissions on the page, then this check should be done before it gets to the controller or after, inside the controller, but not in the lookup for the template

If you want to follow along then you need to remove the template from $ templateCache before you invoke the reload, e.g .:



var currentPageTemplate = $route.current.templateUrl;
$templateCache.remove(currentPageTemplate);
$route.reload();

      

-1


source







All Articles