I need to go through an observable obtained from firebase, where I compare a id
, to be able to create a array with the data belonging to this id
.
' import { Component } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';
//import { DaggService } from '../../providers/dagg-service';
import { FirebaseListObservable, AngularFireDatabase } from 'angularfire2';
import 'rxjs/add/operator/map';
import 'rxjs/Rx';
@Component({
selector: 'page-home',
templateUrl: 'home.html'/*,
providers:[ DaggService ]*/
})
export class HomePage {
regiones: FirebaseListObservable<any>;
provincias: FirebaseListObservable<any>;
ciudades: FirebaseListObservable<any>;
/*public regiones: any;
public provincias: any;
public ciudades: any;*/
constructor(
public navCtrl: NavController,
///public ds: DaggService//,
public alertCtrl: AlertController,
public database: AngularFireDatabase
) {
/*this.regiones = [];
this.provincias = [];
this.ciudades = [];*/
// AQUÍ EXTRAIGO LOS DATOS
this.regiones = this.database.list('/regiones');
this.provincias = this.database.list('/provincias');
this.ciudades = this.database.list('/ciudades');
console.log(this.regiones)
}
getCiudades(provincia){
console.log(provincia)
}
ionViewDidLoad(){
}
}
'
According to the id
obtained, ion-select
goes through the observable of the cities, which contains: IDCIUDAD , NAME CITY e < strong> IDPROVINCIA , to then compare the ** IDPROVINCIA * returned by the ion-select
with that of the observable and create an array of cities depending on the ID of the provinces.