0
私は以下のコードを持っています。私はif (cur !== prev && cur === 100)
をカバーするためにとpreviousValue
とcurrentValue
をどのように使うことができるかを知る必要があります。ngOnChangesを角2のSimpleChangesでテストする
ngOnChanges(changes: SimpleChanges) {
if (changes['highlightData'] && !changes['highlightData'].isFirstChange()) {
const prev: any = changes['highlightData'].previousValue;
const cur: any = changes['highlightData'].currentValue;
if (cur !== prev && cur === 100) {
this._render.setElementClass(this._elementRef.nativeElement, 'animate', true);
setTimeout(() => {
this._render.setElementClass(this._elementRef.nativeElement, 'animate', false);
}, 3000);
}
}
}
どうすればいいですか?おかげさまで