首页 > 解决方案 > How to interpolate in Angular animation

问题描述

<ng-container *ngFor="let obj of mainData | keyvalue">
   <span [@animate]="states.{{obj.key}}">
      //////////////////////////////
   </span>
</ng-container>

I get an error saying that "Expected expression, got interpolation"

标签: angularangular-animations

解决方案


Brackets [] expect a expression, e.g. something like states.obj.key, whereas on normal attributes you have to use interpolation {{}} to insert an expression.

I think what you meant to write is either

[@animate]="states[obj.key]"

or

@animate="{{ states[obj.key] }}"


推荐阅读