1

Hello I have small probelm: How do you clear the cache after you load a view in ui-router in AngularJS. Please help me

2 Answers 2

1

Try this,

app.run(function($rootScope, $templateCache) {
    $rootScope.$on('$routeChangeStart', function(event, next, current) {
        if (typeof(current) !== 'undefined'){
            $templateCache.remove(current.templateUrl);
        }
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for reply, i have jet one question how to reload current view after load it
0

app.controller('mainController', function($scope,$templateCache,$rootScope){
$scope.btnUpdate = function(){
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
}
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.