login.page.ts
import { Component, OnInit } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
@Component({
selector: ‘app-login’,
templateUrl: ‘./login.page.html’,
styleUrls: [’./login.page.scss’],
})
export class LoginPage implements OnInit {
username:string=’’;
constructor(public navCtrl: NavController) { }
ngOnInit() {
}
submit(){
alert('username: ’ + this.username)
}
}
login.page.html
<ion-header>
<ion-toolbar>
<ion-title>login</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<input type=“text” [(ngModel)]=‘username’>
<button (click)=“submit()”>Submit</button>
</ion-content>
when I serve the command it shows the error
Failed to compile.
./src/app/login/login.page.ts
Module not found: Error: Can’t resolve ‘ionic-angular’ in ‘C:\xampp\htdocs\test_ionic\firstionic\src\app\login’
I am using ionic4 beta version.why this error shows.please help anyone
You shouldn’t be using NavController
at all, so if you get rid of all references to it, your problem will go away. The actual proximate cause is that v4 imports from @ionic/angular
, not ionic-angular
.
The previous post should be considered neither a solution nor something to be emulated. Never reference “node_modules” explicitly in imports.
i got the same issue as @asha4640 but i didn’t got any perfect solution because it runs on web but while building and running on app it fails with
vendor.js:48432 ERROR Error: Uncaught (in promise): Error: Cannot find module './login/login.module'
Error: Cannot find module './login/login.module'
Can anyone solve this. Please
for someone who get problem on same. i found the solution.
in your app routing module. try this way of importing
import { LoginPageModule } from './login/login.module';
const routes: Routes = [
{ path: 'login', loadChildren : ()=>LoginPageModule },
];
LoginPageModule
above is the class name and
/login/login.module
this is the file location
do for every path in this way… it solved mine