Angular 错误:没有NavParams的提供程序
当我导航到使用Angular 错误:没有NavParams的提供程序,angular,typescript,ionic2,Angular,Typescript,Ionic2,当我导航到使用NavParams的产品页面时,出现错误。这是我的密码: import { Component } from '@angular/core'; import { NavController, NavParams, AlertController, ModalController } from 'ionic-angular'; @Component({ selector: 'page-product', templateUrl: 'product.html' }) expo
NavParams
的产品页面时,出现错误。这是我的密码:
import { Component } from '@angular/core';
import { NavController, NavParams, AlertController, ModalController } from 'ionic-angular';
@Component({
selector: 'page-product',
templateUrl: 'product.html'
})
export class ProductPage {
data: any;
constructor( public navParams: NavParams ) {
this.tabBarElement = document.querySelector('.tabbar.show-tabbar');
this.data = this.navParams.get('item');
console.log(this.data);
}
}
提前谢谢。转到
AppModule
并将NavParams
添加到提供程序
数组中。对于与文档直接冲突的内容,这一点非常重要。您找到解决方案了吗@帕特里克:真奇怪。app.module.ts或组件的模块中可能存在未导入的模块。但我还没有一个想法。通常,NavParams只需导入和使用即可工作。突然不再。。。(4)