title: Angularjs - hide div with "if" and "else"
body: <p>I would only like to show a div when user is logged in and on their profile but disabled when logged off and on another users profile.</p>
  
  <p>I attempted to do this below but was unsuccessful. I would like to know what is the best possible way of going about this?</p>
  
  <p><code>Service.js</code></p>
  
  <pre><code>(function () {
    'use strict';
  
    angular
      .module('app.authentication.services')
      .factory('Authentication', Authentication);
  
    Authentication.$inject = ['$cookies', '$http'];
  
    function Authentication($cookies, $http) {
  
      var Authentication = {
        getAuthenticatedAccount: getAuthenticatedAccount,
        isAuthenticated: isAuthenticated
      };
  
      return Authentication;
  
      function getAuthenticatedAccount() {
          if(!$cookies.authenticatedAccount) {
              return;
          }
          return JSON.parse($cookies.authenticatedAccount);
      }
      function isAuthenticated() {
          return !!$cookies.authenticatedAccount;
      }  
  })();
  </code></pre>
  
  <p><code>Controller.js</code></p>
  
  <pre><code>(function () {
  'use strict';
  
  angular
      .module('app.profiles.controllers')
      .controller('ProfileController', ProfileController);
  
  ProfileController.$inject = ['$location', '$routeParams', 'Posts', 'Profile', 'Snackbar'];
  
  function ProfileController($location, $routeParams, Posts, Profile, Authentication, Snackbar) {
      var vm = this;
  
      activate();
  
      function activate() {
          var authenticatedAccount = Authentication.getAuthenticatedAccount();
          var username = $routeParams.username.substr(1);
  
           // This will show Cog settings button 
          // when user is logged in and on their profile, 
         // but hidden when logged off and also when on 
         // another users profile
  
          if (!authenticatedAccount) {
              vm.profileCog = false;
              // console.log('User not logged in');
          }
          else {
              if(authenticatedAccount.username !== username) {
                  vm.profileCog = false;
                  // console.log('Not logged in user');
              }
              else {
                  vm.profileCog = true;
                 //console.log('logged in user');
              }
      }
  }
   })();
  </code></pre>
  
  <p><code>profile.html</code></p>
  
  <pre><code>&lt;div ng-controller="ProfileCogController"&gt;
      &lt;div ng-show="!profileCog"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>