Apply a directive conditionally

前端 未结 15 1941
别跟我提以往
别跟我提以往 2020-11-27 15:11

I am using Material 2 to add md-raised-button. I want to apply this directive only if certain condition becomes true.

For example:

<         


        
15条回答
  •  执念已碎
    2020-11-27 15:49

    This could be a solution too:

    [md-raised-button]="condition ? 'true' : ''"


    It's working for angular 4, ionic 3 like this:

    [color]="condition ? 'primary' : ''" where condition is a function that decides if this is an active page or not. The whole code look like this:

提交回复
热议问题