What is a standalone component, and why did Angular move away from NgModules?
Model answer
A standalone component declares its own dependencies in its imports array (other components, directives, pipes) and does not need to belong to an NgModule. In current Angular, components are standalone by default.
NgModules were an extra layer: you had to declare a component in a module and keep module imports in sync. Standalone removes that step, makes code easier to learn and to lazy load, and reduces boilerplate. NgModules still exist in older code, and you may meet them in existing projects.
Tips
- Be ready to say you can read NgModule code even if new code is standalone.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.