Description
Hi,
Something I have discovered today with regards to the controllerAs syntax in Angualr 1. In my Angular 1 application I try to apply the component architecture by using directives to define individual components. The directive has its own controller with controllerAs: 'vm'
. I also use angular-ui router for navigating between views. What I have discovered is that if I have a route defined with controllerAs: 'vm'
and then I use a directive within the view that defines controllerAs: 'vm'
, the vm of the parent controller gets overwritten. The behaviour is the same even with isolated scope on the directive. If however I specify different names in the controllerAs
parameter for router and the directive (ex controllerAs: 'componentVm'
) all works fine.
I was wondering if I am doing something wrong? If not and if this is the intended behaviour it would probably be a good idea to add something to the styleguide mentioning potential controllerAs name conflicts when using component architecture in Angular 1 with directive specific controllers.
Kind regards
Jusef