Angular 有和没有 [] 的指令?

Angular directives with and without []?

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")。

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

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

没错。

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

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