Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 动态地将@ContentChild元素添加到父组件内的特定div中_Angular - Fatal编程技术网

Angular 动态地将@ContentChild元素添加到父组件内的特定div中

Angular 动态地将@ContentChild元素添加到父组件内的特定div中,angular,Angular,是否可以将@ContentChild元素(使用指令)添加到组件模板内的div中?下面给出了HTML模板以供参考 app-component.html: a-component.html: 标题 您可以尝试使用标记。试试下面的方法 a-component.html: 标题 app-component.html: 选择器内的语句将在a组件的中呈现。我知道可以在此处使用ng内容。但是,据我所知,ng内容标签应该出现在模板中。我的要求是创建动态占位符,比如使用ngFor,并将这些a指令元素

是否可以将@ContentChild元素(使用指令)添加到组件模板内的div中?下面给出了HTML模板以供参考

app-component.html:


a-component.html:


标题
您可以尝试使用
标记。试试下面的方法

a-component.html:


标题
app-component.html:



选择器内的语句将在a组件的
中呈现。

我知道可以在此处使用ng内容。但是,据我所知,ng内容标签应该出现在模板中。我的要求是创建动态占位符,比如使用ngFor,并将这些a指令元素添加到占位符中。