ich folgende Angular 2 Richtlinie erstellt:Legendes Winkel/Typoskript Set-Eigenschaft
import { Directive , Input , ViewContainerRef , TemplateRef } from '@angular/core';
@Directive({
selector: '[appUnless]'
})
export class UnlessDirective {
@Input() set appUnless(condition : boolean) {
if(!condition) {
this.vcRef.createEmbeddedView(this.templateRef)
} else {
this.vcRef.clear();
}
}
constructor(private templateRef: TemplateRef<any> , private vcRef: ViewContainerRef) { }
}
und ich es bin mit wie so in meiner Haupt-Winkel HTML-Datei:
<div class="col-md-12">
<p *appUnless="onlyOdd">UNLESS !!!!!!!!!!!!!</p>
</div>
Ich bin nicht ganz verstehen wie der folgende Code funktioniert:
@Input() set appUnless(condition : boolean) {
if(!condition) {
this.vcRef.createEmbeddedView(this.templateRef)
} else {
this.vcRef.clear();
}
}
was genau appUnless
ist, ist es ein Profi oder eine Funktion oder was genau ist es?