如何在角度使用大括号

Per*_*ona -5 angular angular5

我没有得到所需的输出为20.

这有什么问题?

{{x = 4*5}}
Run Code Online (Sandbox Code Playgroud)

Was*_*siF 6

您不能使用赋值运算符,只能使用数字或变量.

这些花括号'{{}}'据说是一个

插值

怎么用?

在你的html模板中,将其写为

X = {{ 4 * 4 }} // X = 16
X = {{ variable * 4 }}
X = {{ variable1 * variable2 }}
Run Code Online (Sandbox Code Playgroud)

这些变量是组件类的属性(控制器类)