5. You want to migrate an Angular app from NgModules to standalone components. Which combination correctly replaces the traditional bootstrap method and module imports?
1. Use bootstrapApplication() instead of platformBrowserDynamic().bootstrapModule()
2. Add standalone: true to components
3. Use imports array inside @Component for dependencies
4. Keep NgModule declarations as before
hard
A. Apply steps 1, 2, and 3; remove NgModules completely
B. Only step 1 is needed; keep NgModules and declarations
C. Apply steps 2 and 4; bootstrapModule remains required
D. Use step 4 only; standalone components are optional
Solution
Step 1: Replace bootstrap method
Use bootstrapApplication() to start the app without NgModules.
Step 2: Convert components to standalone
Add standalone: true to components to remove NgModule dependency.
Step 3: Manage dependencies with imports
Use imports array inside @Component to include needed modules or components.
Step 4: Remove NgModules
NgModules are no longer needed and should be removed for full migration.
Final Answer:
Apply steps 1, 2, and 3; remove NgModules completely -> Option A
Quick Check:
bootstrapApplication + standalone: true + imports array, no NgModules [OK]
Hint: Use bootstrapApplication + standalone + imports, drop NgModules [OK]
Common Mistakes:
Trying to keep NgModules with bootstrapApplication