我如何轻松地将Typescript变量与html标签中的字符串连接 [英] How can i easily concatenate typescript variable with string in html tag

查看:715
本文介绍了我如何轻松地将Typescript变量与html标签中的字符串连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的带有ionic 2的html代码

This is my html code with ionic 2

<ion-item *ngFor="let job of allFreeJobs;let elementid=index">
     <p>
        <span id="m{{elementid}}" (click)="showMore(elementid)" color="primaryAdmin">...<ion-icon name="bicycle"></ion-icon></span>
      </p>
</ion-item>

从上面的代码中可以看出,这是我的专长领域

From the code above this is my area of concentration

... id="m{{elementid}}" ...

如何轻松地将m与变量elementid连接起来.这对我不起作用.

How can I easily concatenate m with the variable elementid. This is not working for me.

推荐答案

Angular文档,您可以使用插值:

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

或属性绑定:

[id]="'m' + elementid"

这篇关于我如何轻松地将Typescript变量与html标签中的字符串连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆