0
似乎在當前版本中,我們只能將動畫添加到組件,並且不能將它們定義爲指令。我的意思是:Angular 2 RC 4指令中不支持的新動畫
下面的工作
@Component({
selector: "animate-demo",
animations: [
trigger('openClose', [
state('closed, void',
style({ height: "0px" })),
state('open',
style({ height: "*" })),
transition("* => *", animate(200))
])
儘管低於不起作用:
@Directive({
selector: "animate-demo",
animations: [
trigger('openClose', [
state('closed, void',
style({ height: "0px" })),
state('open',
style({ height: "*" })),
transition("* => *", animate(200))
])
]
})
並給出編譯錯誤,在Visual Studio:
"Argument of type '{ selector: string; animations: AnimationEntryMetadata[]; template: string; }' is not assignable to parameter of type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'.
平時我們可能想要將常用動畫(如slideDown,slidingdeUp,fadeIn,fadeOut)定義在一個位置作爲目錄然後在我們想要使用它們的組件中,我們只想導入指令並使用動畫,而不是在每個組件中重新定義動畫。