Q: do not working controllerAs in the component I made some modifications to the way the component was created.
The code looks like:


*

*Question is why I should define var navbar = this; pose class ComponentCtrl If I have defined controllerAs : 'navbar' ? 

*Second question is so, if I have in this way I have written the controller, always I should define variables pose class ComponentCtrl to have variable global??
(function () {

 var navbar = this;

class ComponentCtrl {
constructor() { };


$onInit() { 
  navbar.toggle = false;
};


activeMenu(name, $event) {
  console.log(name, navbar.toggle);

  if (navbar.toggle === true && navbar.name == name) {
    navbar.toggle = !navbar.toggle;
  }
  else if (navbar.toggle === false) {
    navbar.toggle = !navbar.toggle;
  }
  navbar.name = name;
};
};

var MyComponent = {
bindings: {
  user: '<'
},
controller: ComponentCtrl,
controllerAs: 'navbar',
templateUrl: '/navbar/index.html'
};

angular.module('app.navbar').component('navbar', MyComponent);
})();

