I'm trying to create a fairly basic directive that can either, hide (remove from DOM), show, or show and disable content inside it depending on user permissions.
As per the angular guide I should be able to do something similar to this to modify content inside a directive.
import { Directive, ElementRef } from '@angular/core';
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective {
constructor(el: ElementRef) {
el.nativeElement.style.backgroundColor = 'yellow';
}
}
However I am having a problem accessing the inner content of the directive. This needs to be a structural directive in order to be able to remove the content from the DOM, but when I make it a structural directive ElementRef only returns a HTML comment element containing the ng bindings, it does not return the actual content.
When I test this as a non-structural directive it returns the actual content.
How do I access the inner content of a structural directive?