angular2 animation with variable styles

前端 未结 3 2107
情书的邮戳
情书的邮戳 2021-02-14 15:07

Using Typescript & Angular 2.0.0-rc.4

How can I specify style property values from the template so that I can re-use buttons? For example, if I wanted to specify a d

3条回答
  •  余生分开走
    2021-02-14 15:22

    As of today you can achieve what you want!

    You can use automatic property calculation!

    In your css or template set background-color to the final color.

    {{bgColor}}

    In your animation definition :

    animations: [
    trigger('state', [
      state('inactive', style({
        'color': '#606060',
        'background-color' : 'transparent'
    
      })),
      state('active', style({
        'color': '#fff',
        'background-color': '*' // <====
      })),
      transition('inactive <=> active', animate('100ms ease-out'))
    ])
    ]
    

    something like this should work!

提交回复
热议问题