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.


    Configure Defaults for Generating Code with Angular CLI

    angular-cliAngular CLI

    The default Angular CLI configuration generates components that consist of 4 files. The component class, an HTML template, a stylesheet and a spec file that contains the unit test.

    In order to keep our components concise we update our AppComponent and move the template and style from an external file to inline. This allows us to delete the 2 external files.

    We can configure our project to generate the template and the style 'inline' by default.

    To do this we run the commands:

    ng config schematics.@schematics/angular.component.inlineStyle true
    ng config schematics.@schematics/angular.component.inlineTemplate true

    The changes are made to angular.json in the project root.



    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: By default, the Angular CLI creates components with an external template and style sheet. In our app component, we rename the template URL property to template, and add the content inside a string literal.

    We rename style URLs to styles, and set the value to an array with string literal. After this is done, we can remove the external files that are no longer used. We can use the ngConfig command to set the defaults for a specific schematic, schematic Angular in this case.

    We set inline style and inline template to true. If we check angular-cli.json in our project root, we see that the defaults are stored there.