和我在:考慮與參考替換函數或lambda到我剛剛更新了我的項目,以角CLI導出函數角度CLI
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "4.0.1",
我收到一個錯誤說:
Consider replacing the function or lambda with a reference to an exported function angular CLI
從這個.ts
文件:
userManagement/userManagement.routing.ts
import {RouterModule, Routes} from "@angular/router";
export const routes: Routes = [
{
path: '', redirectTo: 'unlockUserID', pathMatch: 'full'
},
{
path: 'unlockUserID',
loadChildren:()=> System.import('./unlockUserID/unlockUserID.module')
.then((imports: any)=> imports.UnlockUserIdModule)
},
{
path: 'changePassword',
loadChildren:()=> System.import('./changePassword/changePassword.module')
.then((imports: any)=> imports.ChangePasswordModule)
},
{
path: 'maintainOfficeHierarchy',
loadChildren:()=> System.import('./maintainOfficeHierarchy/maintainOfficeHierarchy.module')
.then((imports: any)=> imports.MaintainOfficeHierarchyModule)
},
];
export const routing = RouterModule.forChild(routes);
比我模塊:
@NgModule({
imports: [
SmartadminModule,
routing,
],
providers: [],
})
export class UserManagementModule {
}
--------------------------------更新1-- ---------------------------
只好改成這樣:
export const routes: Routes = [
{
path: '', redirectTo: 'unlockUserID', pathMatch: 'full'
},
{
path: 'unlockUserID',
loadChildren: './unlockUserID/unlockUserID.module',
data: {pageTitle: 'unlockUserID'}
},
{
path: 'changePassword',
loadChildren: './changePassword/changePassword.module',
data: {pageTitle: 'changePassword'}
},
export const routing: ModuleWithProviders = RouterModule.forRoot(routes, {useHash: true});
現在我正在以下錯誤:
Error: RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.
--------------------------- Update 2-- -------------------------
我改成了
export const routing: ModuleWithProviders = RouterModule.forChild(routes)
;
現在我得到一個錯誤說:
Cannot find 'default' in './changePassword/changePassword.module'
如果我點擊changePassword選項卡,同爲等環節上。
所以我必須徹底改變在這個項目中路由的方式。通過查看以上內容,您是否對痛苦較輕的方式有任何建議。 – Drew1208
@ Drew1208我從來沒有用過這樣的延遲加載,所以我不能推薦任何東西,但這似乎是問題:/如果你想從某個地方讀取路由,你可以創建一個配置文件並將它們添加到那裏。 – echonax
請參閱更新一個 – Drew1208