Let's build a small "Hello World" application with Angular. We'll need a few tools to start our work, such as npm. Refer to Chapter 2, Can We Use JavaScript Server-Side? Sure!, for installation of npm and its friends. If you'd prefer, you can also follow along with the code provided at https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers/tree/master/chapter-8/angular-example.
Here are our steps:
- Begin by installing the Angular CLI: npm install -g @angular-cli.
- Create a new example project with ng new example. Accept the defaults for this installation by pressing Enter at the prompts.
- Go into the directory that was just created: cd example.
- Begin the server: ng serve --open.
At this point, your web browser should open this page at http://localhost:4200/:
Figure 8.3 – Example start page
OK, great. This looks like a simple enough page for us to work with. Here's the file structure that our CLI created...