Apply a directive conditionally

前端 未结 15 1942
别跟我提以往
别跟我提以往 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:35

    I got another idea about what you could do.

    You could store the html you want replaced in a variable as a string and then add / remove the directive from it as you wish, using the bypassSecurityTrustHtml method of the DomSanitizer.

    I doesn't result in a clean solution but at least you don't need to repeat the code.

提交回复
热议问题