我正在尝试创建一个带有输入元素的指令并用div包围它,所以例如,我的html会是这样的:
<input type="text" class="form-control" inputWrapper />
Run Code Online (Sandbox Code Playgroud)
和期望的结果:
<div class="input-wrapper">
<input type="text" class="from-control" />
</div>
Run Code Online (Sandbox Code Playgroud)
指示:
@Directive({
selector: '[inputWrapper]'
})
export class InputWrapperDirective {
constructor(private viewContainerRef: ViewContainerRef, private elementRef: ElementRef) {
// what goes here?
}
}
Run Code Online (Sandbox Code Playgroud)