Angular - FundamentalsHow can you configure different API endpoints for development and production in an Angular project?ASet URLs in package.json scriptsBHardcode URLs in app.component.ts and switch manuallyCStore URLs in src/assets/api.json and read at runtimeDUse src/environments/environment.ts and environment.prod.ts with file replacements in angular.jsonCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify environment config usageAngular uses environment.ts files for different builds, replaced via angular.json settings.Step 2: Reject other optionsHardcoding is error-prone, assets are static files not config, package.json scripts don't manage runtime URLs.Final Answer:Use src/environments/environment.ts and environment.prod.ts with file replacements in angular.json -> Option DQuick Check:Environment files + angular.json file replacements manage API URLs [OK]Quick Trick: Use environment files and angular.json for API URL switching [OK]Common Mistakes:Hardcoding URLs in componentsUsing assets folder for configTrying to set URLs in package.json
Master "Fundamentals" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Modules - Root module (AppModule) structure - Quiz 7medium Component Interaction - Why component communication matters - Quiz 4medium Component Interaction - @Input decorator for parent to child - Quiz 11easy Component Interaction - Child to parent communication flow - Quiz 4medium Components - Creating components with CLI - Quiz 1easy Directives - Why directives are needed - Quiz 15hard Directives - ngStyle for dynamic styles - Quiz 4medium Lifecycle Hooks - ngAfterContentInit for projected content - Quiz 8hard TypeScript in Angular - Enums in Angular applications - Quiz 8hard TypeScript in Angular - Decorators as TypeScript feature - Quiz 13medium