How to pass variable to “data-target=” angular 2

前端 未结 3 1158
天涯浪人
天涯浪人 2021-02-01 01:34

I\'m working with angular 2 typescript and i want to create a toggle collapse list. This is simple with single id and data-target but i loop throught a list so i ha

相关标签:
3条回答
  • 2021-02-01 02:12

    To pass a variable in Angular 7 you can use it just like:

    [attr.data-target] = "theme.themeId"
    
    0 讨论(0)
  • 2021-02-01 02:27

    You could used attribute binding. Something like that:

    [attr.data-target]="'#' + theme.themeId"
    
    0 讨论(0)
  • 2021-02-01 02:28

    Yes exactly you can use

    *ngFor="a of Array; index as i;"
    

    and

    [attr.data-target]="'#test' + i"
    

    and

    name="test{{i}}
    
    0 讨论(0)
提交回复
热议问题