I'm developing an angular application2 and wanted to create dynamic routes, which were generated from a .json file. Searching 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'm uploading 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.module.ts
I do not know what it can be. If someone has a solution that solves this error, or some other way of creating dynamic routes with angular2 would be very useful. I thank you all for your help.