简体   繁体   中英

Angular - How to set <mat-progress-bar> value with an operation?

I have this piece of code

<mat-progress-bar
mode="determinate"
value="10 + 10">
</mat-progress-bar>

But it is not working. If I wrap the value's operation with {{}} it works but I've read that it's not how it should be done. Is that true? How should it be done or is usually done?

The double curly braces are not that clean indeed. Use this instead:

<mat-progress-bar
mode="determinate"
[value]="10 + 10">
</mat-progress-bar>

The brackets indicate that you're entering an expression to evaluate, and not a value. Keep double curly braces for things like string templating.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM