title: MEAN stack authentication - html anchor tag href empty link override ng-click function redirect to base href page
body: <p>I gather several possible solutions none of them work for me. Can someone tell which part has error.</p>
  
  <p>This is the logout function I am working on, the icon should disappear if user click logout and back to login page, but now it only lead to login page. Icon is still there because the function didn't trigger. 
  Everything works only AFTER I click the button in login page, </p>
  
  <p>navigation.service.js</p>
  
  <pre><code>(function() {
  
  angular
      .module('TheApp')
      .service('authentication', ['$window', function($window) {
  
          var saveToken = function(token) {
              $window.localStorage['auth-token'] = token;
          }
  
          var getToken = function() {
              return $window.localStorage['auth-token'];
          }
  
          var logout = function() {
              $window.localStorage.removeItem('auth-token');
              //delete $window.localStorage['auth-token'];
              //$window.localStorage.clear();
          }
  
          var isLoggedIn = function() {
              var token = getToken();
              //Get token from storage If token exists get payload, decode it, and parse it to JSON
              if (token) {
                  let payload = JSON.parse($window.atob(token.split('.')[1]));
                  return payload.exp &gt; Date.now() / 1000;
              } else {
                  return false;
              }
          }
  
  
          return {
              saveToken: saveToken,
              getToken: getToken,
              isLoggedIn: isLoggedIn,
              logout: logout
          };
  
      }])})();
  </code></pre>
  
  <p>navigation.directive.js</p>
  
  <pre><code>(function() {
  angular
      .module('TheApp')
      .directive('navigation', navigation);
  
  function navigation() {
      return {
          restrict: 'EA',
          templateUrl: './common/directives/navigation/navigation.template.html',
          controller: 'navigationCtrl as navvm'
      };
  }})();
  </code></pre>
  
  <p>navigation.controller.js</p>
  
  <pre><code>(function() {
  angular
    .module('TheApp')
    .controller('navigationCtrl', ['$location', 'authentication', '$window', function($location, authentication, $window) {
        console.log("enters navigation controller");
        var vm = this;
  
        vm.isLoggedIn = authentication.isLoggedIn();
        vm.logout = function() {
          console.log('test if the link work');
          authentication.logout();
          $location.path('/login');
        };
    }]);})();
  </code></pre>
  
  <p>navigation.template.html</p>
  
  <pre><code>&lt;ul class="nav navbar-nav navbar-right"&gt;
      &lt;li ng-show="navvm.isLoggedIn"&gt;
      &lt;a href="" ng-click="navvm.logout()"&gt;
      &lt;span aria-hidden="true" class="glyphicon glyphicon-log-out"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Thanks. </p>
  
  <p>Solution(UPDATE):</p>
  
  <p>A careless situation, I omit to put the controller link inside index.html (main template page). So if anyone working on the similar project, the code above should works without errors.</p>