I have a Popover in my app and I want it to behave differently based on the selected item. I followed the instructions in the Ionic documentation to achieve this.
Error: Uncaught (in promise): Error: No provider for ViewController!
When I tried adding ViewController to app.module.ts
, I received the following error:
Uncaught Error: Can't resolve all parameters for ViewController: (?, ?, ?)
Question: How can I properly import ViewController?
Here is the code for the popover component:
import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
selector: 'popover',
templateUrl: 'popover.html'
})
export class PopoverComponent {
popoverItemList = [{name: 'Create Event'}, {name: 'Event Overview'}];
selectedTitle: string;
constructor(private viewCtrl: ViewController) {
this.selectedTitle = "";
}
setSelectedTitle(selectedItem) {
this.selectedTitle = selectedItem;
this.viewCtrl.dismiss(this.selectedTitle);
}
}
The popover is called like this:
presentPopover(ev) {
let popover = this.popoverCtrl.create(PopoverComponent, {
});
popover.present({
ev: ev
});
popover.onDidDismiss((popoverData) => {
if(popoverData === 'Create Event') {
this.navCtrl.push(CreateEventPage, {
});
} else if(popoverData === 'Event Overview') {
this.navCtrl.push(EventlistPage, {
});
}
})