i am trying to add a button to a textarea dynamically through renderer2, in a directive. But the button is not visible. Below is my directive code-
@Directive({
selector: '[appMain]'
})
export class MainDirective {
@Input() initial: string; inText: string;
constructor(private el : ElementRef, private rend: Renderer2) {
let r= this.rend.createElement('button');
let t= this.rend.createText('Click Me!');
this.rend.appendChild(r, t);
this.rend.appendChild(this.el.nativeElement,r);
this.rend.setStyle(r, 'display', 'block');
console.log(this.el.nativeElement);
}
when I console log the nativeElement, the button is visible.snapshot of console.log