How can i easily concatenate typescript variable with string in html tag

后端 未结 3 970
北恋
北恋 2020-12-09 03:44

This is my html code with ionic 2


     

相关标签:
3条回答
  • 2020-12-09 04:20

    you can do this using square brackets,

       [attr.id]="m+'elementid'"
    
    0 讨论(0)
  • 2020-12-09 04:26

    to make interpolation in the attribite of html element in angular you should use [attr.attrName]="expression" or in your case [attr.id]="'m' + elementid"

    0 讨论(0)
  • 2020-12-09 04:28

    As explained in Angular documentation, you can use interpolation:

    id="{{'m' + elementid}}"
    

    or property binding:

    [id]="'m' + elementid"
    
    0 讨论(0)
提交回复
热议问题