Angular 2アニメーションの最後にトリガされる関数を作成しようとしています(最新のAngleCliを使用しています)。Angular 2アニメーション終了コールバック関数の例
私はコードに私の例でコールバック トリガーを割り当てることによってこれがどのように実装されるのかを理解するためにAngular Animationsにいました。ページにアニメーション化されたコンポーネントがあります。持っているコードは次のとおりです。
//first.component.ts
import { Component, OnInit } from '@angular/core';
import { trigger, state, style, animate, transition } from '@angular/core';
@Component({
selector: 'app-first',
templateUrl: './first.component.html',
styleUrls: ['./first.component.css'],
host: {
'[@routeAnimation]': 'true',
'[style.display]': "'block'",
'[style.position]': "'absolute'"
},
animations: [
trigger('routeAnimation', [
state('*', style({transform: 'translateX(0)', opacity: 1})),
transition('void => *', [style({transform: 'translateX(-100%)', opacity: 0}),animate(500)]),
transition('* => void', animate(500, style({transform: 'translateX(100%)', opacity: 0})))
])
]
})
export class FirstComponent implements OnInit {
constructor() { }
ngOnInit() {
}
myFunc() {
// call this function at the end of the animation.
}
}
HTMLはので、任意の助けや簡単な例は、より良い理解を得る私を助けるだろう、私はJavaScriptを使用して、あまりにも慣れていないよ正直に言うと、単に
<div class="w9914420">
<h2>
first-component Works!
</h2>
</div>
div要素であります角度2の
それでは、どのようにONSTART routeAnimationを定義し、例えばfirst.component.tsの関数をやっでしょうか? – W9914420
が私の答えを更新しました。たぶんあなたを助けることができます。 –
私はこの例を高く評価し、私のコードで実装する方法を示します – W9914420