我想使用ng-include
重新加载我在页面中包含的模板<div ng-include="exercise_tpl.url"></div>
我可以通过加载空白模板并再次加载以前的模板
来完成此操作$scope.exercise_tpl.url = 'partials/blank.html';
$('body').trigger('click');
setTimeout(function() {
$scope.exercise_tpl.url = 'partials/memory.html';
$('body').trigger('click');
}, 300);
我想知道在Angularjs中重新加载模板的正确方法。请帮忙。
答案 0 :(得分:-1)
模板被缓存,如果用户没有权限在页面中,那么这个检查应该在它到达控制器之前或在控制器之后,而不是在模板检索之后完成
如果这是你想要遵循的方式,那么你需要在调用reload之前从$ templateCache中删除模板,如:
var currentPageTemplate = $route.current.templateUrl;
$templateCache.remove(currentPageTemplate);
$route.reload();