我已经获得了一个工作链接而没有尝试访问它的参数:
//home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {FishPage} from '../fish';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [FishPage]
})
export class HomePage {
constructor(public navCtrl: NavController, private goFish: FishPage,) {
this.goFish = FishPage;
}
playPoker(){
this.navCtrl.push(FishPage, {
drag: 'ichabod'
});
}
}
该链接有效,直到我将代码添加到FishPage
以访问传入的信息。这是FishPage:
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
@Component({
templateUrl: 'fish.html'
})
export class FishPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
let param = this.navParams.get('drag');
}
}
由于某种原因,代码返回此错误:
[14:18:36]错误:src / pages / home / home.ts(16,4):错误TS2322:类型 'typeof FishPage'不能分配给'FishPage'类型。属性 'typeof FishPage'
类型中缺少'navCtrl'