Environment-Specific Configuration

Explain how to manage different environments in an Angular application using Angular CLI's environment file generation.
// environment.ts
export const environment = {
  production: false,
  apiUrl: 'http://localhost:3000/api'
This is the default environment configuration file for development. It sets production to false and includes a local API URL.
export const environment = {
  production: true,
  apiUrl: ''
This is the environment configuration for the production environment. It sets production to true and includes the production API URL.
import { environment } from './environments/environment';

This code imports the correct environment configuration based on the current environment and logs the API URL to the console.
ng build --prod
Angular CLI command to build the application for production, using the configuration.