Angular:显示数值而不进行更新

huangapple go评论69阅读模式
英文:

Angular : show value without update

问题

<span>{{value}}</span>,但在值更改时不更新此 span
英文:

I want to show value of variable with initial status. I dont want to show update when value is changed

<span>{{value}}</span>

Something like this, but without updating this span when value is changed

答案1

得分: 1

.ts文件:

valueThatWontChange: any

ngOnInit() {
  this.valueThatWontChange = this.value
}

.html文件:

{{ this.valueThatWontChange }}
英文:

.ts:

valueThatWontChange: any

ngOnInit() {
  this.valueThatWontChange = this.value
}

.html:

{{ this.valueThatWontChange }}

huangapple
  • 本文由 发表于 2023年5月22日 22:58:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76307462.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定