如何使用模板连接 Ionic 4 中的字符串?
How to concat string in Ionic 4 with the template?
我需要联系我的 Ionic 4 Full Starter 工具包模板中的名字和姓氏:
<app-text-shell [data]="customer?.surname + customer?.name"></app-text-shell>
遗憾的是他们之间没有space;我能怎么做?如果我在客户 link getNameAndSurname() 中创建函数,则会出现消息错误。
就这么过去
<app-text-shell [data]="customer?.surname +" "+ customer?.name"></app-text-shell>
添加space
+" "+
或
customer = { surname: "weerasinghe", name: "chanaka" };
.html
<app-text-shell [data]="customer"></app-text-shell>
访问数据
this.data.surname
以上答案在 Ionic 4 中对我有用,几乎没有增强。将数据 属性.
中的 "" 替换为 ''
<app-text-shell [data]="details?.min_salary+' '+details?.min_salary"></app-text-shell>
当 'customer' 被定义但仅包含空属性时,这将最终显示 'undefined undefined',而不是应用程序 shell(至少对我而言),因为添加space 确实做到了 non-empty。
所以我的解决方案不是这个:
<app-text-shell [data]="details?.min_salary+' '+details?.min_salary"></app-text-shell>
使用这个:
<app-text-shell [data]="details.min_salary? details.min_salary+' '+details.min_salary : ''"></app-text-shell>
我需要联系我的 Ionic 4 Full Starter 工具包模板中的名字和姓氏:
<app-text-shell [data]="customer?.surname + customer?.name"></app-text-shell>
遗憾的是他们之间没有space;我能怎么做?如果我在客户 link getNameAndSurname() 中创建函数,则会出现消息错误。
就这么过去
<app-text-shell [data]="customer?.surname +" "+ customer?.name"></app-text-shell>
添加space
+" "+
或
customer = { surname: "weerasinghe", name: "chanaka" };
.html
<app-text-shell [data]="customer"></app-text-shell>
访问数据
this.data.surname
以上答案在 Ionic 4 中对我有用,几乎没有增强。将数据 属性.
中的 "" 替换为 ''<app-text-shell [data]="details?.min_salary+' '+details?.min_salary"></app-text-shell>
当 'customer' 被定义但仅包含空属性时,这将最终显示 'undefined undefined',而不是应用程序 shell(至少对我而言),因为添加space 确实做到了 non-empty。 所以我的解决方案不是这个:
<app-text-shell [data]="details?.min_salary+' '+details?.min_salary"></app-text-shell>
使用这个:
<app-text-shell [data]="details.min_salary? details.min_salary+' '+details.min_salary : ''"></app-text-shell>