Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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
Angular 如何将角度5变量绑定到较小的变量?_Angular_Typescript_Less_Angular Template - Fatal编程技术网

Angular 如何将角度5变量绑定到较小的变量?

Angular 如何将角度5变量绑定到较小的变量?,angular,typescript,less,angular-template,Angular,Typescript,Less,Angular Template,我在Angular 5应用程序中使用了这个较少的径向条。现在,它位于组件的HTML模板上,“数据进度”的数字硬编码为75。我可以使用角度绑定大括号将页面上的所有内容绑定到我的TypeScript,这样数据就可用了。但我如何才能将角度数据传递给变量较少的对象呢 我曾考虑过动态生成HTML并通过document.getElementById插入到DIV中,但这只会将原始代码插入到页面中。我的目标是使用这个JS提琴中的HTML和更少,但能够通过TypeScript更改硬编码值75 您不会绑定到一个较

我在Angular 5应用程序中使用了这个较少的径向条。现在,它位于组件的HTML模板上,“数据进度”的数字硬编码为75。我可以使用角度绑定大括号将页面上的所有内容绑定到我的TypeScript,这样数据就可用了。但我如何才能将角度数据传递给变量较少的对象呢

我曾考虑过动态生成HTML并通过document.getElementById插入到DIV中,但这只会将原始代码插入到页面中。我的目标是使用这个JS提琴中的HTML和更少,但能够通过TypeScript更改硬编码值75


您不会绑定到一个较小的变量,您只是被称为
数据进度

<div class="radial-progress" [attr.data-progress]="progress">
然后你就可以基本上一字不差地使用你的小提琴代码了


您可能需要

我已经完全尝试过了,并且得到了“一个不绑定到'data progress'的属性,因为它不是'div'的已知属性”。当我取出数据进度周围的括号时,它显示的与变量名(而不是值)完全相同。就是这样我不知道你是怎么知道要加上“attr.”前缀的,但正是魔法让这一切都起了作用。非常感谢。
<div class="radial-progress" [attr.data-progress]="progress">
progress: number = 0;