1

In my simple web application on Angular 4, I have static pages like about us, contact us etc and if this static pages included as component the size of angular app will increase.

Is there any way to display this static pages via angular app on demand?

3
  • 1
    You can create separate modules for them and load the via lazy loading. That would be ideal way. They won't be downloaded until called. Commented May 21, 2018 at 9:56
  • Could you please give a link to refer? Commented May 21, 2018 at 10:04
  • 1
    alligator.io/angular/lazy-loading Commented May 21, 2018 at 10:14

1 Answer 1

1

You can use lazy loading for this.

Basic idea is to create an module for all your static pages.

This would be ideal way. They won't be downloaded until called.

export const routes: Routes = [
  ...      
  { path: 'pages', loadChildren: './pages/pages.module#PagesModule' },
  ...
];

Import is as :

RouterModule.forChild(routes)

Where PagesModule is your module name to be lazy loaded.

FYI : Lazy Loading Module

Sign up to request clarification or add additional context in comments.

1 Comment

so each static page content should be as a separate component in pages folder, right?

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.