gpt4 book ai didi

javascript - 带或不带 [] 的 Angular 指令?

转载 作者:行者123 更新时间:2023-12-03 00:24:46 26 4
gpt4 key购买 nike

I'm reviewing this tutorial它使用像这样的 tooltip 指令:

情况A:没有周围[]

  <p tooltip="Tooltip from text">Tooltip from text</p>

情况B:周围[]

  <p [tooltip]="template">Tooltip from TemplateRef</p>

我只是想确保我正确理解这一点。

如果我们使用不带括号的 tooltip 指令,则文本字符串将传递给该指令(Tooltip from text")。

当我们用括号包围工具提示时,应该在组件 View (使用指令的 View )上可用的 template 属性会被传入吗?

最佳答案

If we use the tooltip directive without brackets, then the text string gets passed to the directive

是的,完全正确。

对于第二种情况,[tooltip]="template"

[prop] 用于对象绑定(bind)到 Angular 组件的属性(Angular 组件或指令的 @Input() 或 DOM 元素的属性)。

关于javascript - 带或不带 [] 的 Angular 指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54136919/

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