如何在 angular 中使用 HTML 进度条

How to use HTML progress bar with angular

提问人:janci 提问时间:10/23/2023 更新时间:10/23/2023 访问量:32

问:

如何在 Angular 中使用 HTML 内置进度条:

<label for="file">File progress:</label>

<progress id="file" max="100" value="70">30%</progress>

我的意思是如何从 angular 组件动态更改。有什么想法吗?value

HTML 角度 进度条

评论


答:

2赞 InexperiencedCoder 10/23/2023 #1

要在 Angular 中做到这一点,您可以使用“数据绑定”。

在 Angular 组件 TS 文件中,创建一个变量来存储当前进度:

 progressValue: number = 30; 

然后只需插入值,使其是动态的,如下所示:

<label for="file">File progress:</label>
    <progress id="file" max="100" [value]="progressValue">{{ progressValue }}%</progress>

如果要更改进度条,则将在 TS 文件中更改变量。

参考: https://angular.io/guide/binding-syntax