你能在 Angular 2 中声明属性指令的顺序吗

Can you declare order of Attribute directives in Angular 2

我在 following simple pluner 中尝试使用属性指令在我的应用程序中添加(或覆盖)不同的选项。我看到的问题是这些指令的初始化顺序与 DOM 元素中指令的顺序不匹配。

所以即使我按顺序声明它们...

<div jgMoreOptions jgOptions [options]="options">

他们似乎采用了此处应用程序声明中声明的顺序...

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ 
    App,
    OptionsDirective,
    MoreOptionsDirective,
  ],
  bootstrap: [ App ]
})

如果我有多个实现需要以不同顺序加载指令,这就是一个问题。

有没有办法在标签本身中声明指令的顺序?

Here is an example with both directives in a diff order

顺序明确未定义

您需要以某种方式编写代码,以便顺序无关紧要。