I want to create an attribute directive in Angular 2. It needs to have a click handler on its host. The click handler needs to be added before the other directives on the element are evaluated because it controls access to certain functionality. In Angular 1, you could do this with the priority option when creating a directive. Is there some sort of equivalent in Angular 2?
Thanks,
Chase
priority
in Angular 2 is not supported, and there isn't any plan to add it.
Component directives may not use the following attributes:
priority and terminal. While Angular 1 components may use these, they
are not used in Angular 2 and it is better not to write code that
relies on them.
See https://angular.io/docs/ts/latest/guide/upgrade.html#!#using-component-directives
I found that the order the directives are evaluated in in Angular 2 can be defined in the declarations block of the ngModule decorator. Like this:
@NgModule({
imports: [BrowserModule],
// SecondDirective will be evaluated before FirstDirective
declarations: [AppComponent, SecondDirective, FirstDirective],
bootstrap: [AppComponent]
})