我正在嘗試爲RouterModule創建動態路由數組。 作爲don't and do's解釋,我導出函數,如我的路線陣列使用:Angular AOT:不支持函數調用
export function DynamicRoutingCreation() {
let myRoutes;
// .. forEach loop to create dynamic array
}
,並在我的AppModule:
const APP_ROUTES: Routes = DynamicRoutingCreation();
...
RouterModule.forRoot(APP_ROUTES)
但我不斷收到此錯誤:
Error ... Calling function 'DynamicRoutingCreation' , function calls are not supported. Consider replacing the function or lambda with a reference to an exported function.