這是我的路由器供應商的聲明:Angular4 - 路由器模塊提供商AOT
@NgModule({
imports: [RouterModule.forRoot(RoutesFactory.buildRoutes())],
exports: [RouterModule]
})
export class RouterModuleProvider { };
在AOT編譯,我得到這個錯誤:
Error encountered resolving symbol values statically. Calling function 'getRoutes', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol RouterModuleProvider
這裏是RoutesFactory.buildRoutes
的內容static buildRoutes() {
let returnRoutes: Routes = [
{ path: '', redirectTo: '/login', pathMatch: 'full' },
{ path: 'login', component: ViewsModule.LoginViewComponent }
];
let appendRoutes = (items: MenuItem[], routes: Routes) => {
for (let item of items) {
let route: Route = {
path: item.Path, component: item.Component, children: []
};
if (item.Children != null)
appendRoutes(item.Children, route.children)
routes.push(route);
}
};
appendRoutes(RoutesFactory.getMenus(), returnRoutes);
return returnRoutes;
}
RoutesFactory.getMenus()返回一個靜態的內部對象數組。 (沒有從後端加載)
有什麼辦法可以解決這個問題嗎?
你在RoutesFactory.buildRoutes()中有什麼? –
我編輯了自己的問題,以便提供有關此問題的更多詳細信息 – gio
這看起來像是一種非常奇怪的做aot路由的方式。任何理由你這樣做? – mast3rd3mon