Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Use the Angular CLI Environment to Define Constants

    angular-cliAngular CLI

    A default Angular application ships with two default environment files that can store constants that are different for each environment, one for development and the other for production.

    We will define the apiUrl constant in both development and production environments.

    The value for development is http://localhost:3000/api and the value for production is .

    In angular.json we can find a configurations object where our production build is defined. We can see that in a production build, the will replace environment.ts.

    Link to product api used in lessons



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: We open source environments/environments.ts and set the API URL property to our local development API. In the environmental prod.ts, we set the API URL to the production version of the API.

    In angular JSON in our project, we'll find a configuration object that defines our production builds. Inside there, we see that in the production builds, prod file will replace the other.