I try to add an animation in child template:
<div class="panel panel-default" [@AnimationState]="item.animateState" (click)="toggleAnimateState()">
the function toggleAnimateState() in item.component.ts:
toggleAnimateState() {
this.item.animateState = this.item.animateState === 'inactive' ? 'active' : 'inactive';
}
And in the same component :
import { Component, Input ,Output, EventEmitter, trigger, state, style, transition, animate } from "@angular/core";
import { Item as ItemModel} from "./models/Item";
@Component({
selector: 'item',
templateUrl: 'app/item.component.html' ,
styleUrls : ['app/app.component.css'],
animations : [
trigger('AnimationState',[
state('inactive', style({color:'red'})),
state('active', style({color: 'blue'})),
transition('inactive => active' , animate('1000ms eas-in')),
transition('active => inactive' , animate('5000ms eas-in')),
])
]
})
export class Item {
@Input() item : ItemModel;
}
ANd in the app.componet.html:
<div *ngFor="let item of collection | itemFilter:listFilter.value" >
<item [item]="item" (onGetDetails)="onGetDetails($event)"></item>
</div>
But i get this error :
EXCEPTION: Template parse errors:
Can't bind to '@AnimationState' since it isn't a known native property ("
<div class="panel panel-default" [ERROR ->][@AnimationState]="item.animateState" (click)="toggleAnimateState()">
<div class="panel-he"): Item@2:35