Reputation: 1823
I am getting the following error when I tried to implement Popover:
ORIGINAL EXCEPTION: TypeError: Cannot read property 'create' of undefined
Here is my code:
import {Popover, Page, NavController, MenuController, NavParams} from 'ionic-angular';
@Component({
template: 'This is a popover'
})
class MyPopover{}
export class HomePage {
constructor(nav, http, navParams) {}
//PopOver
showPopover(ev){
let popover = Popover.create(MyPopover);
this.nav.present(popover, {
ev: ev
})
}}
Anyone knows why I am getting this? I believe that there is an issue while importing Popover as I am doing the below just after importing Popover:
console.log("Popover object : ",{Popover})
I am getting undefined
so mostly the issue is there.
Upvotes: 0
Views: 1387
Reputation: 44659
I think you were missing the @Component
in your HomePage
@Component({
template: `This is a popover`
})
export class MyPopover{}
// This @Component declaration was missing in your code
@Component({
templateUrl:"build/pages/home/home.html"
})
export class HomePage {
constructor(private nav: NavController) { }
//PopOver
public showPopover(ev){
let popover = Popover.create(MyPopover);
this.nav.present(popover, {
ev: ev
});
}
}
With that (and using beta.9 at least) the popover
is working properly. You can play around with this code in this plunker.
Upvotes: 3