gpt4 book ai didi

javascript - 如何禁用 Angular 缓存

转载 作者:行者123 更新时间:2023-12-03 07:27:35 30 4
gpt4 key购买 nike

Controller 中有两个函数连接到 View 中的两个复选框。问题是,每次我对这些函数进行任何更改时,浏览器都不会检测到。我什至完全删除了这两个功能,浏览器的表现就好像它们仍然存在一样。所有 Firefox 和 Chrome 都会发生这种情况

我在网上做了一些研究,在我看来,这是 Angular 缓存模板的问题。我确实使用 ui-router 但到目前为止

我删除了浏览器缓存,但没有解决问题

我添加了这段代码,但似乎没有任何帮助

app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});

我的代码:

    <div class="checkbox">
<label class='checkboxes' id='checkbox_1'>
<input type="checkbox" ng-model="thirtyDay" ng-change="changeAxis1()">
Last 30 days
</label>
<label class='checkboxes' id='checkbox_2'>
<input type="checkbox" ng-model="wholeTimeline" ng-change="changeAxis2()">
Election timeline
</label>
</div>

Controller :

  $scope.wholeTimeline = true;

$scope.changeAxis2 = function() {
if($scope.wholeTimeline) {
$scope.thirtyDay = false;

alert('is checked')

} else {
alert('is unchecked')
}
};



$scope.changeAxis1 = function() {
if ($scope.thirtyDay) {
$scope.wholeTimeline = false;
alert('is checked')

}else {
alert('is unchecked')
}
};

最佳答案

您是否尝试过在 Firefox/Chrome 中使用匿名/隐身模式。

据此,在该模式下永远不会使用缓存: https://www.quora.com/Does-incognito-mode-on-Chrome-use-the-cache-that-was-previously-stored

关于javascript - 如何禁用 Angular 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35937965/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com