Become a member
to unlock all features

Level Up!

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


    Say "Hello World" to Angular 2

    5 - 6

    The quickest way to get started with Angular 2 is to use the Angular CLI. The Angular CLI allows you to create new projects and startup a server in just a couple quick commands. This lesson shows how to install the cli, start the server, and make a simple change.



    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




    Install the Angular CLI with npm install -g, for globally, angular-cli. Give that some time to install, and then you'll have a command called ng, where you can say ng new and the name of your project. I'm going to name mine angular 2-fundamentals. Once that has run, you can change into that directory, angular 2-fundamentals. Once you're in this directory, if you type ng serve and hit enter, that's the Angular CLI command to start up a server with the project you just installed.

    Once this is ready, you'll see that the bundle is now VALID. So this server is available on localhost 4200. So let that run, and you'll see app works. To change this, you can go into your project. Just open it in any editor. This angular 2-fundamentals directory, go into src, app, app.component.ts, and you'll see this 'app works'. You can change this to whatever you want. I'm going to change it to 'Let's get started!'

    Hit save, and you'll see the browser will automatically refresh, and you'll see Let's get started!