On an Angular 7 application I have the following component:
export class ListComponent implements OnInit {
visible: boolean;
ngOnInit() {
this.visible = false;
}
toggle() {
this.visible = !this.visible
}
}
And on the view I have:
<table *ngIf="visible">
Table content
</table>
Is there any difference between setting the initial value of visible inside ngOnInit or in variable declaration, e.g:
visible: boolean = false;
Which approach is better?