I am using Angular4 and I have some data value that I want to insert dynamically as an id in data-target.
What I do this is works fine:
<a href="#" data-toggle="modal" data-target="#myid">Edit</a>
But when I do this:
<a href="#" data-toggle="modal" data-target="#{{item.id}}">Edit</a>
For some reason the line above is converting to this:
<a href="#" data-toggle="modal" target="#{{item.id}}">Edit</a>
So, no longer data target by turns to target.
Why? and how can I fix this?
您可以尝试使用角度属性绑定而不是插值:
<a href="#" data-toggle="modal" [attr.data-target]="'#' + item.id">Edit</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.