Is there something special to do when using Component Inheritance ?
edit : this concerns INHERITANCE, not parent/child view/components communication
as I try to hide a div defined in the base class template, it does not work
in the page, the variable is not even updated even if it gets modified in the code
1st, I tried with [hidden] and *ngIf
then I tried using changeDetectorRef but it does not do anything
it seems the value is not propagated to the template
base class:
@Component({
selector: 'my-content',
templateUrl: './content.component.html',
styleUrls: ['./content.component.css'],
})
export class ContentComponent implements OnInit {
protected overlayVisible:boolean;
constructor(....){...}
ngOnInit() {
}
showOverlay()
{
this.overlayVisible=true; <<<<<<<<<<<<<< THESE GET CALLED
}
hideOverlay()
{
this.overlayVisible=false; <<<<<<<<<<<<<< THESE GET CALLED
}
}
base template (content.component.html):
<div>
<div class="contentMainDiv">
<div class="contentBodyDiv"><ng-content select="[body]"></ng-content></div>
<div [innerHTML]=" overlayVisible?'true':'false' "></div> /// DEBUG DIV
<div [hidden]="!overlayVisible" class="contentOverlay" >
<my-wait></my-wait>
</div>
</div>
</div>
child component :
export class CustomersComponent extends ContentComponent implements OnInit {
private customers: any;
constructor(
private customersService: CustomersService,
injector:Injector
) { super(injector); }
getCustomers() {
this.showOverlay();
this.customersService.getCustomers().subscribe((customers: any) => {
this.customers = customers;
this.hideOverlay();
});
}
child template :
<my-content>
<div body>
<div *ngIf="customers">
some table ...
</div>
</div>
</my-content>
what am I missing
is there something special to do when we use component inheritance ?
thanks