1

I'm trying to make some button disappear when I logout, but if I don't put reload command It won't reload and button wouldn't disappear. After I put reload command view doesn't change because the process end at reload line.

Here my code :

$scope.logout = function(){
    deleteCookie("Username","/");
    location.reload();
    $location.path('/view1');


}

Please help !

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'});
}]);
Kitsakorn P
  • 111
  • 1
  • 10

3 Answers3

0

You can use absolute url or just add target="_self" on your <a> tag, if you use it in your HTML.

P.S.
  • 15,970
  • 14
  • 62
  • 86
0

I suggest this approach..

     $scope.logout = function(){
     deleteCookie("Username","/");

        if (-----)  {   //deletecokkie value is null 
       window.location = "http://.../..."  //full URL of the designation;
          }

    }
Aman
  • 806
  • 2
  • 12
  • 38
  • Thanks for reply, I add $stat but error shows up Unknown provider: $stateProvider <- $state <- Logincontroller Do I have to setup some thing in my app.js ? – Kitsakorn P Nov 16 '16 at 11:21
  • I have update my question above thank you so much for helping sir ! – Kitsakorn P Nov 16 '16 at 11:26
  • $stateProvider wont work for you because you are not using it. i have updated my answer please see that – Aman Nov 16 '16 at 11:32
  • Thanks for helping, but window.location only change view. No reload happen :( – Kitsakorn P Nov 16 '16 at 11:38
  • you dont need to reload the whole page without any reason.. if you wanted to hide the button just make the button hide when you are clicking on logout – Aman Nov 16 '16 at 12:03
0

To reload to another view, simply use:

$state.go("your_view_name");

Hope this helps!

Andre Debuisne
  • 303
  • 1
  • 3
  • 15