我想得到這個結果,拜托了。
img - 登錄/示例
我的專案結構是這樣的
img - 結構
目前,我的輸入沒有顯示???
img - 登錄/我的結果
我的輸入是在singin.component.html 上
<div >
<form (ngSubmit)="login()">
<div >
<div >
<label for="email" style="min-width: 100px !important">User</label>
<input type="text" name="email" style="width: 70%" aria-describedby="emailHelp" [(ngModel)]="loginForm.user" required maxlength="4">
</div>
</div>
<div >
<div >
<label for="password" style="min-width: 100px !important">Password</label>
<input type="password" name="password" style="width: 70%" [(ngModel)]="loginForm.password" required maxlength="4">
</div>
</div>
<button type="submit" >Connection</button>
</form>
</div>
我認為問題在于identity-routing.module.ts檔案,SinginCompoent 不與 IdentityComponent 互動。
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IsActivate } from '../../core/isActivate.guard';
import { IdentityComponent } from './identity.component';
import { SinginComponent } from './view/singin/singin.component';
export const IDENTITY_ROUTES: Routes = [
{
path: '',
component: IdentityComponent,
},
{
path: 'identity',
component: IdentityComponent,
canActivate: [IsActivate],
children:[
{
path: '',
pathMatch: 'full',
redirectTo: 'singin'
},
{
path:'singin',
component: SinginComponent,
}
]
},
];
@NgModule({
imports: [RouterModule.forChild(IDENTITY_ROUTES)],
exports: [RouterModule],
})
export class IdentityRoutingModule {}
app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{
path: '',
loadChildren: () => import('./views/identity/identity.module').then((m) => m.IdentityModule),
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
我可以給你我的代碼Stackblitz。
uj5u.com熱心網友回復:
改變:
export const IDENTITY_ROUTES: Routes = [
{
path: '',
component: IdentityComponent,
},
{
path: 'identity',
component: IdentityComponent,
canActivate: [IsActivate],
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'singin',
},
{
path: 'singin',
component: SinginComponent,
},
],
},
];
到:
export const IDENTITY_ROUTES: Routes = [
{
path: '',
component: IdentityComponent,
canActivate: [IsActivate],
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'singin',
},
{
path: 'singin',
component: SinginComponent,
},
],
},
];
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/402115.html
標籤:有角的
