gpt4 book ai didi

javascript - 带计算的 Angular 数据绑定(bind)

转载 作者:行者123 更新时间:2023-11-30 12:23:11 26 4
gpt4 key购买 nike

这似乎是一个非常简单的问题,但我无法在任何地方找到答案。

在 AngularJS 中使用数据绑定(bind)时:

<iframe height="{{bodyHeight}}"> </iframe>

我只想从 bodyHeight 中减去一个数字,类似于:

<iframe height="{{bodyHeight - 90}}"> </iframe>

我希望不使用 javascript 就可以做到这一点。

最佳答案

您所拥有的确实有效!

您可以在 angularJS 的 {{ }} 数据绑定(bind)中进行计算和其他 javascript!

来自angularJS documentation

Angular expressions are JavaScript-like code snippets that are usuallyplaced in bindings such as {{ expression }}.

For example, these are valid expressions in Angular:

1+2

a+b

user.name

items[index]

关于javascript - 带计算的 Angular 数据绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30356842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com