Mig*_*ada 5 typescript angular2-directives angular
我有一个简单的指令,根据接收的属性为给定的HTML元素添加一些属性.
<button class="btn btn-blue x-large" [myDirective]="{ some_json_data: true }">
Unfold
</button>
Run Code Online (Sandbox Code Playgroud)
该myDirective指令只是在ngOnInit钩子中做了一些逻辑并装饰了ElementRef原生元素(在这种情况下是按钮)添加属性,没有什么复杂的.
ngOnInit(): void {
const el: Element = this.element.nativeElement;
this.decorate(el, this.myDirective);
}
Run Code Online (Sandbox Code Playgroud)
基于给定的逻辑(在myDirective装饰中)我想向ElementRefat 引用的元素添加工具提示(这是另一个指令)myDirective.
如何手动挂载指令以及如何将其添加到元素(ViewContainerRef)?
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |