Closed SamVerschueren closed 8 years ago
I personnally always use controllerAs: vm
in all my current (angular 1.4) directives. I think it makes it easier to use a consistent name when writing the view, as I don't have to remember what the name is when writing the view.
Where does vm
stand for? Think I might go with ctrl
, just like Angular 1.5. Seems also like the best option in terms of upgrading an Angular 1.5 application to use Angular2-polyfill. It won't force the user to change the templates because the reference to the controller is the same as it was before (in Angular 1.5).
At the moment, the
controllerAs
value is the camelcase variant of the component selector. For instance, if the selector ismy-heroes
, thecontrollerAs
value ismyHeroes
.When I decided that, it looked like a good suggestion, but is it? I noticed that when refactoring, and changing the
selector
of the component, it always ends up in a find-and-replace in the view.Angular 1.5 uses
$ctrl
in the view to refer to the controller. The benefit is that it doesn't change when the selector changes. Any other ideas for this?