Arman Davari
Arman Davari

Reputation: 33

Cannot find Ionic-angular module

I'm Learning Ionic v4 and the template are compiled successfully. But when I change these template to components examples like this one below, It gives error that I mention below.

What did i do wrong? And if the process I made for testing alert is wrong, how can I test codes and add pages in ionic?

I would be grateful if anyone can help me learn to use ionic. I have project to deliver in 2 weeks Thanks

import { Component } from '@angular/core';

import { AlertController } from 'ionic-angular';


@Component({
  templateUrl: 'template.html'
})
export class BasicPage {

  constructor(public alerCtrl: AlertController) { }

  doAlert() {
    let alert = this.alerCtrl.create({
      title: 'New Friend!',
      message: 'Your friend, Obi wan Kenobi, just approved your 
friend request!',
      buttons: ['Ok']
    });
    alert.present()
  }

}

ERROR in ./src/app/tab3/tab3.module.ts 16:58- 66 [ng] "export 'Tab3Page' was not found in './tab3.page' [ng] ERROR in ./src/app/tab3/tab3.module.ts 18:23- 31 [ng] "export 'Tab3Page' was not found in './tab3.page' [ng] ERROR in ./src/app/tab3/tab3.page.ts [ng] Module not found: ./src/app/tab3/tab3.page.ts [ng] Module not found: Error: Can't resolve 'ionic-angular' in 'C:\Users\ASUS\Ionic\ app\src\app\tab3' [ng] Time: 797ms [ng] i 「wdm」: Failed to compile. [ng] [ng] ERROR in src/app/tab3/tab3.module.ts(6,10): error TS2305: Module '"C:/Users/ASUS/Ionic/app /src/app/tab3/tab3.page"' has no exported member 'Tab3Page'. [ng] src/app/tab3/tab3.page.ts(3,33): error TS2307: Cannot find module 'ionic-angular'**

Upvotes: 2

Views: 7719

Answers (4)

Anjali Sharma
Anjali Sharma

Reputation: 535

update this.

import { AlertController } from 'ionic-angular';

it will be

import { AlertController } from '@ionic/angular';

In ionic4, its changed that's why you are getting an error.

visit this link

Upvotes: 0

user11907741
user11907741

Reputation:

There are various update in Ionic4.

import { AlertController } from '@ionic/angular';  // Ionic 4

import { AlertController } from 'ionic/angular';  // Ionic 3

Upvotes: 5

Cahit Karahan
Cahit Karahan

Reputation: 66

Looks like your tab3 component(tab3.page.ts) is ok but there is problems with your tab3 module(tab3.module.ts same folder). Best way to get rid of this error is deleting tab3 page and recreating page with below command.

ionic generate page tab3

Upvotes: 0

Chanaka Weerasinghe
Chanaka Weerasinghe

Reputation: 5742

you can add page using command line it will wire all things

https://ionicframework.com/docs/cli/commands/generate

ionic generate page your_page_name

Upvotes: 1

Related Questions