Popover not passing data?


#1

After following the docs I add a popover to my page and it works great. The issue I have is it is not passing the data, or Im doing it wrong.

This is how I am calling the popover…

  presentPopover(myEvent) {
    let popover = Popover.create(AuditActionsPage,{audit:this.audit.id});
    this.nav.present(popover, {
      ev: myEvent
    });
  }

In the popover component, Im trying to access the data as follows but no data comes through…

  constructor(view,sql,params,events) {
    this.view = view;
    this.sql = sql;
    this.events = events;
    this.params = params;
    this.audit = params.get('audit');
    console.log(this.audit);
  }

Any Ideas?

Cordova CLI: 6.2.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.8
Ionic CLI Version: 2.0.0-beta.30
Ionic App Lib Version: 2.0.0-beta.16
ios-deploy version: 1.7.0
ios-sim version: 3.0.0
OS: Mac OS X El Capitan
Node Version: v4.3.0
Xcode version: Xcode 7.3.1 Build version 7D1014


#2

@relevantidea Are there any errors in the console? Maybe there’s something with the DI. Could you post more code from the popover component - imports, DI-code (static get parameters())?


#3

Sure, here ya go.

import {ViewController,NavParams,Events,NavController} from 'ionic-angular';
import {Component} from '@angular/core';

import {SqlService}    from '../../relevant/sql/sql';

@Component({
  templateUrl: 'build/pages/audit-compliance/audit-compliance.html',
})
export class AuditCompliancePage {
  static get parameters() {
    return [[ViewController],[SqlService],[NavParams],[Events]];
  }

  constructor(view,sql,params,events) {
    this.view = view;
    this.sql = sql;
    this.events = events;
    this.params = params;
    console.log(this.params);
    this.audit = params.get('audit'); 
  }

  close(){
    this.view.dismiss();
  }
}

#4

I’m sort of lost because in the first post we’re referencing AuditActionsPage, but in the last one it’s named AuditCompliancePage.


#5

The code looks OK but, as @rapropos mentioned, it seems that there’s an inconsistency in the names of the pages. I took a look at the source code of the Popover component and it looks fine. A plunker with a similar but simplified use-case also works OK. Therefore I would recommend you to check your code for errors. If you didn’t manage to find the problem could you try to isolate it in a plunker using the following one as template.


#6

Yeah, I was looking at it too long and shared the wrong page. But I was also working with the wrong page which is why it wasn’t working. Once he pointed that out I realized I needed to walk away for a few. Thanks, sorry to waste the time.


#7

It happens, I’m glad that you figured it out.