{ "id": "tutorial/toh-pt0", "title": "Create a new project", "contents": "\n\n\n
You begin by creating an initial application using the Angular CLI. Throughout this tutorial, you’ll modify and extend that starter application to create the Tour of Heroes app.
\nIn this part of the tutorial, you'll do the following:
\n For the sample app that this page describes, see the
To set up your development environment, follow the instructions in Local Environment Setup.
\nYou develop apps in the context of an Angular workspace. A workspace contains the files for one or more projects. A project is the set of files that comprise an app, a library, or end-to-end (e2e) tests. For this tutorial, you will create a new workspace.
\nTo create a new workspace and an initial app project:
\nEnsure that you are not already in an Angular workspace folder. For example, if you have previously created the Getting Started workspace, change to the parent of that folder.
\nRun the CLI command ng new and provide the name angular-tour-of-heroes, as shown here:
The ng new command prompts you for information about features to include in the initial app project. Accept the defaults by pressing the Enter or Return key.
The Angular CLI installs the necessary Angular npm packages and other dependencies. This can take a few minutes.
It also creates the following workspace and starter project files:
\nangular-tour-of-heroes.angular-tour-of-heroes (in the src subfolder).The initial app project contains a simple Welcome app, ready to run.
\nGo to the workspace directory and launch the application.
\nThe ng serve command builds the app, starts the development server,\nwatches the source files, and rebuilds the app as you make changes to those files.
The --open flag opens a browser to http://localhost:4200/.
You should see the app running in your browser.
\nThe page you see is the application shell.\nThe shell is controlled by an Angular component named AppComponent.
Components are the fundamental building blocks of Angular applications.\nThey display data on the screen, listen for user input, and take action based on that input.
\nOpen the project in your favorite editor or IDE and navigate to the src/app folder to make some changes to the starter app.
You'll find the implementation of the shell AppComponent distributed over three files:
app.component.ts— the component class code, written in TypeScript.app.component.html— the component template, written in HTML.app.component.css— the component's private CSS styles.Open the component class file (app.component.ts) and change the value of the title property to 'Tour of Heroes'.
Open the component template file (app.component.html) and\ndelete the default template generated by the Angular CLI.\nReplace it with the following line of HTML.
The double curly braces are Angular's interpolation binding syntax.\nThis interpolation binding presents the component's title property value\ninside the HTML header tag.
The browser refreshes and displays the new application title.
\n\nMost apps strive for a consistent look across the application.\nThe CLI generated an empty styles.css for this purpose.\nPut your application-wide styles there.
Open src/styles.css and add the code below to the file.
Here are the code files discussed on this page.
\n