2

I have an Angular 5 project. Is this possible to do the next structure?

/app
 /folder1
  /comp1
  /comp2
  folder1.module.ts
 /folder2
  /comp1
  /comp2
  folder2.module.ts
app-routing.ts
...
...

So, my angular project knows nothing about this folders (folder1, folder2, etc) and I need to include them to app-routing dynamically by parameter value from url.

For example. Url: localhost:1111/folder1

and in app-routing.ts I want to have something like

const appRoutes: Routes = [
  {
    path: ':folderName',
    loadChildren: () => {
      var module = './{:folderName}.module';
      return import(module).then((comp: any) => {
        return comp.default;
      });
    }
  },

  {
    path: '',
    component: BaseComponent
  }
];

Is this possible or maybe any other options?

Thanks

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.