在角度2中,除了两组引号之外,还有更好的方法将字符串传递通过输入吗? [英] In angular 2 is there a better way to pass a string through an input other than two sets of quotes?

查看:46
本文介绍了在角度2中,除了两组引号之外,还有更好的方法将字符串传递通过输入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在输入中传递字符串值而不是表达式.模板将在服务器端生成那些字符串值.我可以使它正常工作,但是使用类似于以下内容的代码:

I'm trying to pass a string value instead of an expression through in input. The template will have those string values generated on the server side. I can get this working, but using code similar to the following:

<my-app [guidValue]="'some-guid-value'"></my-app>

两组引号(嵌套在双引号中的单引号)感觉不对.还有另一种将其声明为字符串值的方法吗?或者这真的是做到这一点的方法吗?

The two sets of quotes (single quotes nested inside double quotes) feels wrong. Is there another way of declaring this as a string value or is this really the way to do it?

推荐答案

您可以使用以下内容:

<my-app guidValue="some-guid-value"></my-app>

这样,值将在相应的输入中设置为字符串.

This way the value will set as a string in the corresponding input.

这篇关于在角度2中,除了两组引号之外,还有更好的方法将字符串传递通过输入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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