How add button listener on typescript

i got this method called openMapPage() that returns all the user key with reqdetails. Is any there way i can don’t use push page, but instead when i click on nearby button it just goes to openMapPage() and render’s all data to the request.html page?


  <ion-navbar color="primary">
    <ion-title name="title">Job Requests</ion-title>

<ion-content padding>
  <div class="filter">
<button class="islandwide" ion-button large>Islandwide</button>
<button class="nearby" ion-button large (click)="openMapPage()" id="nb">Nearby</button>

  <ion-card *ngFor="let user of request | async" class="job">
     <button ion-item (click)="goToJobDetails(user.$key)" class="info">
    <ion-avatar class="avatar" item-start>
        <img src="../assets/icon/user_male-512.png">
    <h2 class="name">{{user.regdetails.username}}</h2>
    <p text-wrap class="address"><ion-icon name="compass"></ion-icon> {{user.regdetails.address}}</p>
    <p id="key">{{user.$key}}</p>


openMapPage() method

  var ref = firebase.database().ref("request");
    ref.once("value").then((snapshot) => { // <------ Here!
        var a = snapshot.exists();  // true
        var c = snapshot.hasChild("reqdetails"); // true
        var d = snapshot.child('reqdetails').exists();
        var requestsKey = snapshot.key;
        var requestsValue = snapshot.val();

        snapshot.forEach((childSnapshot) => { // <------ And here!
            var requestKey = childSnapshot.key;
            var requestValue = childSnapshot.val();

            var reqdetails = requestValue.reqdetails;
            if (reqdetails) {

       = requestKey;

        this.navCtrl.push(RequestsPage, {
        //this.navCtrl.push(RequestsPage, { 'param1': });

How does this happen without pushing the page?

OK i meant when i click the openMapPage() method, how do i return back the data to the request.html page?

Do you want openMapPage to be a modal that collects information? If so, follow the code example in ModalController. You can send data through the ViewController dismiss.

There’s no way to return the data to request.html? like example if else statement if clicked on openMapPage() method?

Out of curiosity, how much of that documentation did you read before asking me this question?

1 Like