2017-04-18 19:29:55 -04:00
|
|
|
@title
|
|
|
|
CLI QuickStart
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
@description
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Good tools make application development quicker and easier to maintain than
|
|
|
|
if you did everything by hand.
|
|
|
|
|
|
|
|
The [**Angular CLI**](https://cli.angular.io/) is a **_command line interface_** tool
|
|
|
|
that can create a project, add files, and perform a variety of ongoing development tasks such
|
|
|
|
as testing, bundling, and deployment.
|
|
|
|
|
|
|
|
The goal in this guide is to build and run a simple Angular
|
|
|
|
application in TypeScript, using the Angular CLI
|
2017-04-30 16:10:32 -04:00
|
|
|
while adhering to the [Style Guide](guide/styleguide) recommendations that
|
2017-03-30 16:01:15 -04:00
|
|
|
benefit _every_ Angular project.
|
|
|
|
|
|
|
|
By the end of the chapter, you'll have a basic understanding of development with the CLI
|
|
|
|
and a foundation for both these documentation samples and for real world applications.
|
|
|
|
|
|
|
|
You'll pursue these ends in the following high-level steps:
|
|
|
|
|
|
|
|
1. [Set up](guide/cli-quickstart#devenv) the development environment.
|
|
|
|
2. [Create](guide/cli-quickstart#create-proj) a new project and skeleton application.
|
|
|
|
3. [Serve](guide/cli-quickstart#serve) the application.
|
|
|
|
4. [Edit](guide/cli-quickstart#first-component) the application.
|
|
|
|
|
2017-04-20 07:33:31 -04:00
|
|
|
And you can also <a href="/content/zips/cli-quickstart/cli-quickstart.zip" target="_blank">download the example.</a>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id='devenv'>
|
|
|
|
Step 1. Set up the Development Environment
|
|
|
|
</h2>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
You need to set up your development environment before you can do anything.
|
|
|
|
|
|
|
|
Install **[Node.js® and npm](https://nodejs.org/en/download/)**
|
|
|
|
if they are not already on your machine.
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
<div class="l-sub-section">
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
**Verify that you are running at least node `6.9.x` and npm `3.x.x`**
|
|
|
|
by running `node -v` and `npm -v` in a terminal/console window.
|
|
|
|
Older versions produce errors, but newer versions are fine.
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Then **install the [Angular CLI](https://github.com/angular/angular-cli)** globally.
|
|
|
|
|
|
|
|
|
|
|
|
<code-example language="sh" class="code-shell">
|
2017-03-31 19:57:13 -04:00
|
|
|
npm install -g @angular/cli
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
</code-example>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-30 16:10:32 -04:00
|
|
|
<h2 id='create-proj'>
|
2017-03-30 16:01:15 -04:00
|
|
|
Step 2. Create a new project
|
|
|
|
</h2>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Open a terminal window.
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Generate a new project and skeleton application by running the following commands:
|
|
|
|
|
|
|
|
|
|
|
|
<code-example language="sh" class="code-shell">
|
2017-03-31 19:57:13 -04:00
|
|
|
ng new my-app
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
</code-example>
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
<div class="l-sub-section">
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Patience please.
|
|
|
|
It takes time to set up a new project, most of it spent installing npm packages.
|
|
|
|
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id='serve'>
|
|
|
|
Step 3: Serve the application
|
|
|
|
</h2>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Go to the project directory and launch the server.
|
|
|
|
|
|
|
|
|
|
|
|
<code-example language="sh" class="code-shell">
|
2017-03-31 19:57:13 -04:00
|
|
|
cd my-app
|
|
|
|
ng serve --open
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
</code-example>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
The `ng serve` command launches the server, watches your files,
|
|
|
|
and rebuilds the app as you make changes to those files.
|
|
|
|
|
|
|
|
Using the `--open` (or just `-o`) option will automatically open your browser
|
|
|
|
on `http://localhost:4200/`.
|
|
|
|
|
|
|
|
Your app greets you with a message:
|
|
|
|
|
|
|
|
|
|
|
|
<figure class='image-display'>
|
2017-04-26 08:11:02 -04:00
|
|
|
<img src='content/images/guide/cli-quickstart/app-works.png' alt="The app works!"></img>
|
2017-03-30 16:01:15 -04:00
|
|
|
</figure>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 id='first-component'>
|
|
|
|
Step 4: Edit your first Angular component
|
|
|
|
</h2>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
The CLI created the first Angular component for you.
|
|
|
|
This is the _root component_ and it is named `app-root`.
|
|
|
|
You can find it in `./src/app/app.component.ts`.
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Open the component file and change the `title` property from _app works!_ to _My First Angular App_:
|
|
|
|
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
<code-example path="cli-quickstart/src/app/app.component.ts" region="title" title="src/app/app.component.ts" linenums="false">
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
</code-example>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
The browser reloads automatically with the revised title. That's nice, but it could look better.
|
|
|
|
|
|
|
|
Open `src/app/app.component.css` and give the component some style.
|
|
|
|
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
<code-example path="cli-quickstart/src/app/app.component.css" title="src/app/app.component.css" linenums="false">
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
</code-example>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<figure class='image-display'>
|
2017-04-26 08:11:02 -04:00
|
|
|
<img src='content/images/guide/cli-quickstart/my-first-app.png' alt="Output of QuickStart app"></img>
|
2017-03-30 16:01:15 -04:00
|
|
|
</figure>
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Looking good!
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
## What's next?
|
|
|
|
That's about all you'd expect to do in a "Hello, World" app.
|
|
|
|
|
2017-04-30 16:10:32 -04:00
|
|
|
You're ready to take the [Tour of Heroes Tutorial](tutorial) and build
|
2017-03-30 16:01:15 -04:00
|
|
|
a small application that demonstrates the great things you can build with Angular.
|
|
|
|
|
|
|
|
Or you can stick around a bit longer to learn about the files in your brand new project.
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
## Project file review
|
|
|
|
|
|
|
|
An Angular CLI project is the foundation for both quick experiments and enterprise solutions.
|
|
|
|
|
|
|
|
The first file you should check out is `README.md`.
|
|
|
|
It has some basic information on how to use CLI commands.
|
|
|
|
Whenever you want to know more about how Angular CLI works make sure to visit
|
|
|
|
[the Angular CLI repository](https://github.com/angular/angular-cli) and
|
|
|
|
[Wiki](https://github.com/angular/angular-cli/wiki).
|
|
|
|
|
|
|
|
Some of the generated files might be unfamiliar to you.
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
### The `src` folder
|
|
|
|
Your app lives in the `src` folder.
|
|
|
|
All Angular components, templates, styles, images, and anything else your app needs go here.
|
|
|
|
Any files outside of this folder are meant to support building your app.
|
|
|
|
|
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='filetree'>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
src
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.component.css
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.component.html
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.component.spec.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.component.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.module.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
assets
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
.gitkeep
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
environments
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
environment.prod.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
environment.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
favicon.ico
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
index.html
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
main.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
polyfills.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
styles.css
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
test.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
tsconfig.app.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
tsconfig.spec.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
td, th {vertical-align: top}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<table width="100%">
|
|
|
|
|
|
|
|
<col width="20%">
|
|
|
|
|
|
|
|
</col>
|
|
|
|
|
|
|
|
<col width="80%">
|
|
|
|
|
|
|
|
</col>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<th>
|
|
|
|
File
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<th>
|
|
|
|
Purpose
|
|
|
|
</th>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>app/app.component.{ts,html,css,spec.ts}</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Defines the `AppComponent` along with an HTML template, CSS stylesheet, and a unit test.
|
|
|
|
It is the **root** component of what will become a tree of nested components
|
|
|
|
as the application evolves.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>app/app.module.ts</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-04-30 16:10:32 -04:00
|
|
|
Defines `AppModule`, the [root module](guide/appmodule "AppModule: the root module") that tells Angular how to assemble the application.
|
2017-03-31 19:57:13 -04:00
|
|
|
Right now it declares only the `AppComponent`.
|
|
|
|
Soon there will be more components to declare.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>assets/*</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
A folder where you can put images and anything else to be copied wholesale
|
|
|
|
when you build your application.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>environments/*</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
This folder contains one file for each of your destination environments,
|
|
|
|
each exporting simple configuration variables to use in your application.
|
|
|
|
The files are replaced on-the-fly when you build your app.
|
|
|
|
You might use a different API endpoint for development than you do for production
|
|
|
|
or maybe different analytics tokens.
|
|
|
|
You might even use some mock services.
|
|
|
|
Either way, the CLI has you covered.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>favicon.ico</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Every site wants to look good on the bookmark bar.
|
|
|
|
Get started with your very own Angular icon.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>index.html</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
The main HTML page that is served when someone visits your site.
|
|
|
|
Most of the time you'll never need to edit it.
|
|
|
|
The CLI automatically adds all `js` and `css` files when building your app so you
|
|
|
|
never need to add any `<script>` or `<link>` tags here manually.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>main.ts</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
The main entry point for your app.
|
|
|
|
Compiles the application with the [JIT compiler](guide/glossary#jit)
|
|
|
|
and bootstraps the application's root module (`AppModule`) to run in the browser.
|
|
|
|
You can also use the [AOT compiler](guide/glossary#ahead-of-time-aot-compilation)
|
|
|
|
without changing any code by passing in `--aot` to `ng build` or `ng serve`.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>polyfills.ts</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Different browsers have different levels of support of the web standards.
|
|
|
|
Polyfills help normalize those differences.
|
|
|
|
You should be pretty safe with `core-js` and `zone.js`, but be sure to check out
|
2017-04-30 16:10:32 -04:00
|
|
|
the [Browser Support guide](guide/browser-support) for more information.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>styles.css</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Your global styles go here.
|
|
|
|
Most of the time you'll want to have local styles in your components for easier maintenance,
|
|
|
|
but styles that affect all of your app need to be in a central place.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>test.ts</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
This is the main entry point for your unit tests.
|
|
|
|
It has some custom configuration that might be unfamiliar, but it's not something you'll
|
|
|
|
need to edit.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>tsconfig.{app|spec}.json</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
TypeScript compiler configuration for the Angular app (`tsconfig.app.json`)
|
|
|
|
and for the unit tests (`tsconfig.spec.json`).
|
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
### The root folder
|
|
|
|
The `src/` folder is just one of the items inside the project's root folder.
|
|
|
|
Other files help you build, test, maintain, document, and deploy the app.
|
|
|
|
These files go in the root folder next to `src/`.
|
|
|
|
|
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='filetree'>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
my-app
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
e2e
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='children'>
|
|
|
|
|
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.e2e-spec.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
app.po.ts
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
tsconfig.e2e.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
node_modules/...
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
src/...
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
.angular-cli.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
.editorconfig
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
.gitignore
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
karma.conf.js
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
package.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
protractor.conf.js
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
README.md
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
tsconfig.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
<div class='file'>
|
2017-03-30 16:01:15 -04:00
|
|
|
tslint.json
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-04-11 16:44:52 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
td, th {vertical-align: top}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<table width="100%">
|
|
|
|
|
|
|
|
<col width="20%">
|
|
|
|
|
|
|
|
</col>
|
|
|
|
|
|
|
|
<col width="80%">
|
|
|
|
|
|
|
|
</col>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<th>
|
|
|
|
File
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<th>
|
|
|
|
Purpose
|
|
|
|
</th>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>e2e/</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Inside `e2e/` live the End-to-End tests.
|
|
|
|
They shouldn't be inside `src/` because e2e tests are really a separate app that
|
|
|
|
just so happens to test your main app.
|
|
|
|
That's also why they have their own `tsconfig.e2e.json`.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>node_modules/</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
`Node.js` creates this folder and puts all third party modules listed in
|
|
|
|
`package.json` inside of it.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>.angular-cli.json</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Configuration for Angular CLI.
|
|
|
|
In this file you can set several defaults and also configure what files are included
|
|
|
|
when your project is build.
|
|
|
|
Check out the official documentation if you want to know more.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>.editorconfig</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Simple configuration for your editor to make sure everyone that uses your project
|
|
|
|
has the same basic configuration.
|
|
|
|
Most editors support an `.editorconfig` file.
|
|
|
|
See http://editorconfig.org for more information.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>.gitignore</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
Git configuration to make sure autogenerated files are not commited to source control.
|
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>karma.conf.js</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Unit test configuration for the [Karma test runner](https://karma-runner.github.io),
|
|
|
|
used when running `ng test`.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>package.json</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
`npm` configuration listing the third party packages your project uses.
|
|
|
|
You can also add your own [custom scripts](https://docs.npmjs.com/misc/scripts) here.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>protractor.conf.js</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
End-to-end test configuration for [Protractor](http://www.protractortest.org/),
|
|
|
|
used when running `ng e2e`.
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>README.md</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Basic documentation for your project, pre-filled with CLI command information.
|
|
|
|
Make sure to enhance it with project documentation so that anyone
|
|
|
|
checking out the repo can build your app!
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>tsconfig.json</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
TypeScript compiler configuration for your IDE to pick up and give you helpful tooling.
|
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
<code>tslint.json</code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
Linting configuration for [TSLint](https://palantir.github.io/tslint/) together with
|
|
|
|
[Codelyzer](http://codelyzer.com/), used when running `ng lint`.
|
|
|
|
Linting helps keep your code style consistent.
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
<div class="l-sub-section">
|
2017-03-30 16:01:15 -04:00
|
|
|
|
2017-03-31 19:57:13 -04:00
|
|
|
|
|
|
|
|
2017-03-30 16:01:15 -04:00
|
|
|
### Next Step
|
|
|
|
|
2017-04-30 16:10:32 -04:00
|
|
|
If you're new to Angular, continue with the
|
|
|
|
[tutorial](tutorial "Tour of Heroes tutorial").
|
2017-03-30 16:01:15 -04:00
|
|
|
You can skip the "Setup" step since you're already using the Angular CLI setup.
|
|
|
|
|
2017-04-10 11:51:13 -04:00
|
|
|
</div>
|
2017-03-30 16:01:15 -04:00
|
|
|
|