我想确保isSearchVisible范围变量总是false在每次页面更改时开始。我应该如何实施?
app.controller('MainController', function($rootScope) {
$rootScope.isSearchVisible = false;
});
app.controller('ProfileController', function($scope) {
$scope.isSearchVisible = true;
});
app.controller('AboutUsController', function($scope) {
});
在每个页面中,根范围变量isSearchVisible是false因为MainController.
当您进入配置文件页面 ( ProfileController) 时,本地范围变量变为true,这很好。
但是当您离开此页面时,根范围变量也更改为true. $rootScope变量和变量之间没有分离$scope。
除非控制器直接更改它,否则我应该如何在每次页面更改时重置isSearchVisible?false