I have one child component, which have a particular html code and I want to show it for certain parent components only. I followed below method but it didn't work for me
child.ts
button = true
child.html
<div *ngIf="button">
..........show/hide me
</div>
...........................................................
parent.ts
@Input()button
ngOnInit(){
this.button = false}
parent.html
<child [button]="button"></child>
"..........show/hide me" should not be render in parent. but its there
Mistake is in the child component.
button = true
needs to be
@Input() button = true
refer to this https://stackblitz.com/edit/angular-niuksv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.