Reputation: 2023
I have my HomepageComponent that holds a custom directive MapDirective, bound to the selector name myMap.
In homepage.component.html
...
<div myMap position=??></div>
...
I would like the directive to be loaded only after I retrieved the location from my HomepageComponent, so that I can center my map on the user location when I display it.
This requires to wait a little bit so that I can retrieve the location using navigator.geolocation.getCurrentPosition async call.
Is it possible to do so ?
Upvotes: 1
Views: 278
Reputation: 1710
If you want to display a div or other tag with condition, you can use *ngIf
<div *ngIf="position" myMap position=??></div>
So you will only display position div when you resolve the promise of getposition call
Upvotes: 1