2

I have learnt that we can lazy load modules in an angular 2 application. But similarly is it possible to lazy load simply a component(instead of wrapping it in a module) : https://angular.io/docs/ts/latest/guide/ngmodule.html#!#lazy-load

Edit How to share resources like Components, Directives and Services between the main module and lazily loaded module?

1 Answer 1

3

No, only modules are supported to be lazy loaded.

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

10 Comments

Why can't we do that with a module loader like systemJs or maybe requireJs?
Why would you want to? One of the main points of @NgModule is to make lazy loading work with all bundlers. If you want to lazy load a single component, than make a module that only contains that component.
Isn't creating a module every tiny reusable component like a small widget an overhead though?
Sure it's an overhead. Why do you think you need to lazy load a small widget on its own?
In case I need to include that widget in two separate lazily loaded views.
|

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.