Within the method itself Shows the value, but outside it shows undefined message
Ubigeo.service.ts
 lisProvinciaByDepartamento( ubigeoId: string): Observable<Ubigeo[]> {
    let ubigeo$ = this.http
    .get(`${this.baseUrl}/provincia/${ubigeoId}`, {headers: this.getHeaders()})
    .map(mapUbigeos)
    .catch(handleError);
    return ubigeo$;
}
Detail.component.ts
cargaPronvicia(ubigeoId: string) {
    this._ubigeoService
        .lisProvinciaByDepartamento(ubigeoId)
        .subscribe((p) => {
            this.provinciaSeleccionada = p
                .find(item =>
                    item.ubigeoId.substr(2, 2) === ubigeoId.substr(2, 2));
            this.provincias = p;
            console.log(this.provinciaSeleccionada); //2
        });
    console.log(this.provinciaSeleccionada); //1
}
 
    