简要说明:尝试在home.html
页面上实施popover控制器。试图按照文档但仍然无法通过。
我在popover.ts
旁边创建了home.ts
页面,但当我尝试在home.ts
中导入时,它会说Cannot find module 'popover'
。
我做错了什么?
home.ts
import { PopoverController } from 'ionic-angular';
import { PopoverPage } from 'popover';
@Component({})
class MyPage {
constructor(public popoverCtrl: PopoverController) {}
presentPopover(myEvent) {
let popover = this.popoverCtrl.create(PopoverPage);
popover.present({
ev: myEvent
});
}
}
popover.ts
import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
template: `
<ion-list>
<ion-list-header>Ionic</ion-list-header>
<button ion-item (click)="close()">Learn Ionic</button>
<button ion-item (click)="close()">Documentation</button>
<button ion-item (click)="close()">Showcase</button>
<button ion-item (click)="close()">GitHub Repo</button>
</ion-list>
`
})
class PopoverPage {
constructor(public viewCtrl: ViewController) {}
close() {
this.viewCtrl.dismiss();
}
}
答案 0 :(得分:5)
尝试这个
<强> home.ts 强>
import { PopoverController } from 'ionic-angular';
import { PopoverPage } from './popover';
@Component({})
export class MyPage {
constructor(public popoverCtrl: PopoverController) {}
presentPopover(myEvent) {
let popover = this.popoverCtrl.create(PopoverPage);
popover.present({
ev: myEvent
});
}
}
<强> popover.ts 强>
import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
template: `
<ion-list>
<ion-list-header>Ionic</ion-list-header>
<button ion-item (click)="close()">Learn Ionic</button>
<button ion-item (click)="close()">Documentation</button>
<button ion-item (click)="close()">Showcase</button>
<button ion-item (click)="close()">GitHub Repo</button>
</ion-list>
`
})
export class PopoverPage {
constructor(public viewCtrl: ViewController) {}
close() {
this.viewCtrl.dismiss();
}
}