我试图让一些按钮消失,当我注销,但如果我不把重新加载命令它不会重新加载和按钮不会消失。在我把重新加载命令视图不会改变,因为过程在重载行结束。AngularJS如何重新载入然后重定向到另一个视图?
这里我的代码:
$scope.logout = function(){
deleteCookie("Username","/");
location.reload();
$location.path('/view1');
}
请帮帮忙!
UPATE:app.js
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.viewLogin',
'myApp.SaveCafeDetail',
'myApp.viewUserprofile',
'myApp.viewManageuser',
'myApp.viewEditcafe',
'myApp.version'
]).
config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
把deleteCookie放在if if标签 – Aman
@AyanAman这是否会导致问题? –
你是如何消失的按钮? – Chetan