Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在html样式标记中使用javascript变量_Javascript_Html_Variables_Tags - Fatal编程技术网

如何在html样式标记中使用javascript变量

如何在html样式标记中使用javascript变量,javascript,html,variables,tags,Javascript,Html,Variables,Tags,在我的angular2项目中,我想使用一个进度条,它链接到ts文件中的一个变量 因此,变量如下所示: public width = 60; 然后在我的html文件中,我有一个html标记,看起来像: style="width: 50%" ,我想将其链接到该变量 我最好的猜测是它看起来像style=“width:{{{width}}%”,这是不正确的。如果您只是想设置元素的宽度,您可以选择它并从那里进行设置。阅读文档…使用ngStyle:不,我不能在html文件中设置它。。它需要是可变的

在我的angular2项目中,我想使用一个进度条,它链接到ts文件中的一个变量

因此,变量如下所示:

public width = 60;
然后在我的html文件中,我有一个html标记,看起来像:

style="width: 50%"
,我想将其链接到该变量


我最好的猜测是它看起来像
style=“width:{{{width}}%”
,这是不正确的。

如果您只是想设置元素的宽度,您可以选择它并从那里进行设置。阅读文档…使用ngStyle:不,我不能在html文件中设置它。。它需要是可变的