Question presented to candidate: "We are starting a new Angular 22 app. What is a standalone component, why is it the default now, and what does it change about how we bootstrap and lazy load?"
What a strong answer should cover:
- A standalone component declares its own template dependencies in
importsand belongs to no NgModule. - Default since v19: the
standaloneflag istrueunless you writestandalone: false; the same applies to directives and pipes. - Bootstrapping uses
bootstrapApplication(App, appConfig), with app-wide providers (provideRouter,provideHttpClient) inappConfig. - Lazy loading works per component with
loadComponent, no wrapper module needed. - Benefits: less boilerplate, dependencies visible per file, better tree-shaking, simpler tests (
imports: [Component]in TestBed). - Interop with NgModules in both directions, and an automated migration (
ng generate @angular/core:standalone).
Clarifying questions expected:
- "Is there an existing NgModule codebase we need to interoperate with?"
- "Do you want me to cover lazy loading and providers, or only the component itself?"
Code / implementation expected: Yes β a standalone component that imports a pipe, a directive and a child component.