0
I am developing an angular2 application and wanted to create dynamic routes, which would be generated from a .json.file. Searching I found the following code:
import { Routes ,RouterModule } from '@angular/router';
export const routes: Routes = getScreens();
export const routing = RouterModule.forRoot(routes);
export function getScreens() {
var results :Array<Object> = Array<Object>();
let screens :Array<any> = [
{
"title": "Home",
"path": "home",
"component" : "app/home/home.module"
},
{
"title":"Team",
"path":"team",
"component": "app/team/team.module"
}
];
results.push({ path: '' ,redirectTo: 'home', pathMatch:'full'});
for (let entry of screens) {
results.push({ path: entry.path, loadChildren: entry.component});
}
return results;
}
But the following error happens when I go up the application
client? 93b6:101 Error encountered resolving Symbol values statically. Calling Function 'getScreens', Function calls are not supported. Consider replacing the Function or lambda with a Reference to an Exported Function, resolving Symbol Routes in C:/Users/02501699165/Downloads/Angular2 Resetrouter/angular2-routertest/src/app/app.routing.ts, resolving Symbol routing in C:/Users/02501699165/Downloads/Angular2 Resetrouter/angular2-routertest/src/app/app.routing.ts, resolving Symbol routing in C:/Users/02501699165/Downloads/Angular2 Resetrouter/angular2-routertest/src/app/app.routing.ts, resolving Symbol Appmodule in C:/Users/02501699165/Downloads/Angular2 Resetrouter/angular2-routertest/src/app/app.module.ts, resolving Symbol Appmodule in C:/Users/02501699165/Downloads/Angular2 Resetrouter/angular2-routertest/src/app/app.modulets.
I don’t know what it might be. If someone has a solution that solves this error, or some other way to create dynamic routes with angular2 would be very useful. I appreciate all your help.