大佬教程收集整理的这篇文章主要介绍了angular – 创建自定义结构指令,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
说明:我有一对字符串数组的元素让我们调用数组标题的n个元素的第一个元素和第二个描述
这是https://ibb.co/i23Dxa的结果
(数组来自后端,我通过模拟数组文件模拟它)
现在,如果我调用我需要创建的结构指令,我希望它显示我将在该调用下编写的内容
<ng-template aulos-configuration-item-toolbar> <button (click)="click()">just click</button> </ng-template>
import { Directive,Input,TemplateRef,ViewContainerRef } from "@angular/core"; @Directive({ SELEctor: "[aulos-configuration-item-toolbar]",}) export class AulosConfigurationItemToolbar { public templateRef: TemplateRef<any>; constructor(templateRef: TemplateRef<any>) { this.templateRef = templateRef; } }
有人可以更好地解释我的进展方式吗?非常感谢.
export class GridoptionsComponent { } @Directive({ SELEctor: 'grid-options' }) @Component({ SELEctor: 'my-grid',modulEID: module.id,templateUrl: './grid.component.html' }) export class GridComponent { .... .... }
grid.component.html看起来像
<div class="col-md-3"> <div> some more html elements,components </div> <ng-content SELEct="grid-options"></ng-content> </div>
并且应该在另一个组件中使用
<my-grid> <grid-options> <button >Add</button> <button >View</button> </grid-options> </my-grid>
以上是大佬教程为你收集整理的angular – 创建自定义结构指令全部内容,希望文章能够帮你解决angular – 创建自定义结构指令所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。