I need your help please
I would like to load myFunction when my page is load with ngOnInit(). But it's don't work.
.
.
myData: any = [];
.
.
.
ngOnInit()
{
this.myFunction();
}
myFunction()
{
return this.restApi.getMydata().subscribe((data: {}) => {
this.myData = data;
}
I try to put a button
<button type="submit" class="btn" value = "submit" (click) = "myFunction()" >test</button>
And it work.
Why ngOnInit() don't load it ?
If you could help me, Thanks a lot.