No provider for NavParams!

#1

Hi, I created a basic tabbed application using :
ionic start myApp tabs --type=angular

My home.page.ts has :

import { Component } from '@angular/core';
import { TestPage } from '../test/test.page';
import { NavController, NavParams  } from '@ionic/angular';
@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss']
})
export class HomePage {
  constructor(public navCtrl: NavController, public navParams: NavParams) {}
  hello(){
    //this.presentAlert();
    //console.log("sdsadsadasdasdsadasdsad");
      this.navCtrl.navigateForward('/test');
  }
}

But i am getting the error as :

Uncaught (in promise): Error: StaticInjectorError(AppModule)[HomePage -> NavParams]: StaticInjectorError(Platform: core)[HomePage -> NavParams]: NullInjectorError: No provider for NavParams!

How to fix this:

my Ionic version is 4.0.0 beta 7

2 Likes
#2

If you are looking into navigate to test page refer the below documentation for ionic navigation between pages.

Ionic Nav controller and add the pages you have created into imports in the app.module.ts

#3

NavParams doesn’t exist in v4

2 Likes
#5

This is not true. NavParams exists, but it can only be used on things like Modals

#6

yes true, modals and popovers