Rellationship tables in ionic?


#1

I have TABLE1 and TABLE2, how to relate them
TABLE1 - id, name
TABLE2 - id, name, TABLE1_id

my service-provider.ts

  getTABLE1() {
    let headers = new Headers({ 'Authorization': 'Bearer ' + window.localStorage.getItem('token') });
    let options = new RequestOptions({ headers: headers });
    return this.http.get(this.api+'table1' , options).map( res => res.json());
  }

in my pageTABLE1.ts

table1: any[];

  constructor(public navCtrl: NavController, public navParams: NavParams, public service: ServiceProvider, public alertCtrl: AlertController) {
    this. initializeTable1();
    this.loading();
  }


  initializeTable1() {
    this.service.getTABLE1()
        .subscribe(
          data => this.table1 = data.table1,
          e => console.log(e)
        );
  }


  navigateTo(table1_id) {
    this.navCtrl.push(pageTABLE2, {
      table1_id: table1_id
    });
  }

how to make in pageTable2 get id Table1 and show table2.table1_id = table1.id ?
My my pageTABLE2.ts

table2: any[];

  constructor(public navParams: NavParams, public navCtrl: NavController, public service: ServiceProvider) {
    this.table1_id = navParams.get('table1_id');
    this.initializeTable2();
  }
  initializeTable2() {
    this.service.getTABLE2()
        .subscribe(
          data => this.table2 = data.table2,
          e => console.log(e)
        );
  }

I want to show table2 when table2.table1_id = table1.id ?