Reputation: 1
Firstly, when i login the error show:
ERROR Error: Uncaught (in promise): Error: Cannot find module '../home/home.module' Error: Cannot find module '../home/home.module'
Here the code for the error part:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {Routes, RouterModule} from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { MenuPage } from './menu.page';
const routes: Routes =[
{
path: '',
component: MenuPage,
children: [
{
path: 'home',
loadChildren: '**../home/home.module#HomePageModule**'
}, /* '../home/home.module#HomePageModule' */
{
path: 'tabs',
loadChildren: () => import('../tabs/tabs.module').then( m => m.TabsPageModule)
}, /* '../tabs/tabs.module#TabsPageModule' */
{
path: 'status',
loadChildren: '../status/status.module#StatusPageModule'
},
{
path: 'butiranmaklumat',
loadChildren: '../butiran-maklumat/butiran-maklumat.module#ButiranMaklumatPageModule'
},
{
path: 'tabs/butiranmaklumat',
loadChildren: '../butiran-maklumat/butiran-maklumat.module#ButiranMaklumatPageModule'
},
{
path: 'butiranpekerjaan',
loadChildren: '../butiran-pekerjaan/butiran-pekerjaan.module#ButiranPekerjaanPageModule'
},
{
path: 'tabs/butiranpekerjaan',
loadChildren: '../butiran-pekerjaan/butiran-pekerjaan.module#ButiranPekerjaanPageModule'
},
{
path: 'butiranpasangan',
loadChildren: '../butiran-pasangan/butiran-pasangan.module#ButiranPasanganPageModule'
},
{
path: 'tabs/butiranpasangan',
loadChildren: '../butiran-pasangan/butiran-pasangan.module#ButiranPasanganPageModule'
},
{
path: 'maklumattanggungan',
loadChildren: '../maklumat-tanggungan/maklumat-tanggungan.module#MaklumatTanggunganPageModule'
},
{
path: 'tabs/maklumattanggungan',
loadChildren: '../maklumat-tanggungan/maklumat-tanggungan.module#MaklumatTanggunganPageModule'
},
{
path: 'sejarahpermohonan',
loadChildren: '../sejarah-permohonan/sejarah-permohonan.module#SejarahPermohonanPageModule'
},
{
path: 'tabs/sejarahpermohonan',
loadChildren: '../sejarah-permohonan/sejarah-permohonan.module#SejarahPermohonanPageModule'
}
/* {
path: '',
redirectTo: 'home',
pathMatch: 'full'
}
*/
]
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [MenuPage]
})
export class MenuPageModule {}
So, i try to delete ".." on the bold line and write back ".." . and it can successfully login. But the other error show:
ERROR TypeError: datas.pr_master_pengguna is not iterable
Here the code for this part:
import { Component, OnInit } from '@angular/core';
import {Provider} from '../../providers/provider';
import {Router} from '@angular/router';
import {Storage} from '@ionic/storage';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage {
LoginPengguna:string;
KataLaluan:string;
task:any[];
constructor(
private provider:Provider,
private router:Router,
private storage: Storage
) { }
login(){
return new Promise(resolve =>{
let body = {
LoginPengguna:this.LoginPengguna,
KataLaluan:this.KataLaluan
};
this.provider.postData(body, 'login.php').subscribe(data => {
// console.log(data);
if(data['user']){
this.storage.set('IdPengguna', data['user'][0]['IdPengguna']);
this.router.navigate(['menu/tabs/tabs/home']);
}else {
alert("Login failed");
}
});
})
}
}
but for this error, i just refresh it and data show.
So i try to terminate and run it back. and the error still show the same. it just like cache in my code. Hopefully u guys can help.
Upvotes: 0
Views: 364
Reputation: 5742
Error was this part
children: [
{
path: 'home',
loadChildren: '**../home/home.module#HomePageModule**'
}, /* '../home/home.module#HomePageModule' */
change it
// Full path including `src` at the start:
loadChildren: '/home/home.module#HomePageModule'
or this:
// Relative path from the `app-routing.module.ts` file:
loadChildren: './home/home.module#HomePageModule'
Upvotes: 0