How to call custom function after ngSwitch new view is created

Hi there, could you share your code with us? I’m still looking for a solution… my code is still not working, what I’m doing wrong?
This is my code:
.html:

<ion-header>
  <ion-navbar>
   <ion-segment [(ngModel)]="dashboard" (change)="onSegmentChanged($event)">
        <ion-segment-button value="list">
          Liste
        </ion-segment-button>
        <ion-segment-button value="map">
          Karte
        </ion-segment-button>
      </ion-segment>
  
  </ion-navbar> 
</ion-header>

<ion-content>
  <div [ngSwitch]="dashboard">

    <div *ngSwitchCase="'list'">
        some content...
    </div>
      
      <div *ngSwitchCase="'map'">
        <div #map id="map"></div>
      </div>

    </div>

.ts

 initMap() {

        let LatLng = new google.maps.LatLng(52.491114, 13.394625);

        let mapOptions = {
            center: LatLng,
            zoom: 15,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
    }

    onSegmentChanged($event) {
        if ($event == 'map') {
            this.initMap();
         }
    }

.scss

  #map{
    height:100%;
  }

Would really appreciate, thank you!