在 AngularJS 1.6 中,组件可以用作元素的属性吗?
Can component be used on element as an attribute in AngularJS 1.6?
AngularJS 指令 的 1.6 文档指出:
$compile can match directives based on element names (E), attributes (A), class names (C), and comments (M).
(...)
The following demonstrates the various ways a directive (myDir in this case) that matches all 4 types can be referenced from within a template.
<my-dir></my-dir>
<span my-dir="exp"></span>
<!-- directive: my-dir exp -->
<span class="my-dir: exp;"></span>
你能用同样的方法使用组件,通过属性将它们添加到HTML元素吗?因为组件的文档总是显示组件被用作 elements.
的示例
为了澄清,而不是像下面那样写它并用非标准元素弄乱我的标记:
<component-name></component-name>
我希望能够在我的 HTML:
中做类似的事情
<h1 component-name=""></h1>
整个网络都在向组件化方向发展。我不会担心 "non-standard elements." 无论如何,组件仅限于元素。它们不能用于属性。这是指令与组件的主要用例。
组件专门用于创建 HTML 并使用基于视图的行为对其进行扩充。指令现在主要用于装饰 HTML。
AngularJS 指令 的 1.6 文档指出:
$compile can match directives based on element names (E), attributes (A), class names (C), and comments (M).
(...)
The following demonstrates the various ways a directive (myDir in this case) that matches all 4 types can be referenced from within a template.
<my-dir></my-dir> <span my-dir="exp"></span> <!-- directive: my-dir exp --> <span class="my-dir: exp;"></span>
你能用同样的方法使用组件,通过属性将它们添加到HTML元素吗?因为组件的文档总是显示组件被用作 elements.
的示例为了澄清,而不是像下面那样写它并用非标准元素弄乱我的标记:
<component-name></component-name>
我希望能够在我的 HTML:
中做类似的事情<h1 component-name=""></h1>
整个网络都在向组件化方向发展。我不会担心 "non-standard elements." 无论如何,组件仅限于元素。它们不能用于属性。这是指令与组件的主要用例。
组件专门用于创建 HTML 并使用基于视图的行为对其进行扩充。指令现在主要用于装饰 HTML。