Skip to content

Commit 4917715

Browse files
Broccohansl
authored andcommitted
docs: move documentation from readme to wiki (angular#4576)
1 parent 1656f3f commit 4917715

File tree

4 files changed

+44
-293
lines changed

4 files changed

+44
-293
lines changed

README.md

Lines changed: 1 addition & 293 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,9 @@ with NPM 3 or higher.
3737
* [Usage](#usage)
3838
* [Generating a New Project](#generating-and-serving-an-angular2-project-via-a-development-server)
3939
* [Generating Components, Directives, Pipes and Services](#generating-components-directives-pipes-and-services)
40-
* [Generating a Route](#generating-a-route)
41-
* [Creating a Build](#creating-a-build)
42-
* [Build Targets and Environment Files](#build-targets-and-environment-files)
43-
* [Base tag handling in index.html](#base-tag-handling-in-indexhtml)
44-
* [Bundling](#bundling)
45-
* [Running Unit Tests](#running-unit-tests)
46-
* [Running End-to-End Tests](#running-end-to-end-tests)
47-
* [Proxy To Backend](#proxy-to-backend)
48-
* [Linting code](#linting-code)
49-
* [Commands autocompletion](#commands-autocompletion)
50-
* [Project assets](#project-assets)
51-
* [Global styles](#global-styles)
52-
* [CSS preprocessor integration](#css-preprocessor-integration)
53-
* [3rd Party Library Installation](#3rd-party-library-installation)
54-
* [Global Library Installation](#global-library-installation)
5540
* [Updating Angular CLI](#updating-angular-cli)
5641
* [Development Hints for hacking on Angular CLI](#development-hints-for-hacking-on-angular-cli)
42+
* [License](#license)
5743

5844
## Installation
5945

@@ -112,284 +98,6 @@ Interface | `ng g interface my-new-interface`
11298
Enum | `ng g enum my-new-enum`
11399
Module | `ng g module my-module`
114100

115-
### Generating a route
116-
117-
The CLI supports routing in several ways:
118-
119-
- We include the `@angular/router` NPM package when creating or initializing a project.
120-
121-
- When you generate a module, you can use the `--routing` option like `ng g module my-module --routing` to create a separate file `my-module-routing.module.ts` to store the module routes.
122-
123-
The file includes an empty `Routes` object that you can fill with routes to different components and/or modules.
124-
125-
The `--routing` option also generates a default component with the same name as the module.
126-
127-
- You can use the `--routing` option with `ng new` to create a `app-routing.module.ts` file when you create or initialize a project.
128-
129-
<!-- DeleteSection1 Start here to remove upon next release -->
130-
### Creating a build
131-
132-
```bash
133-
ng build
134-
```
135-
136-
The build artifacts will be stored in the `dist/` directory.
137-
138-
### Build Targets and Environment Files
139-
140-
`ng build` can specify both a build target (`--target=production` or `--target=development`) and an
141-
environment file to be used with that build (`--environment=dev` or `--environment=prod`).
142-
By default, the development build target and environment are used.
143-
144-
The mapping used to determine which environment file is used can be found in `angular-cli.json`:
145-
146-
```json
147-
"environments": {
148-
"source": "environments/environment.ts",
149-
"dev": "environments/environment.ts",
150-
"prod": "environments/environment.prod.ts"
151-
}
152-
```
153-
154-
These options also apply to the serve command. If you do not pass a value for `environment`,
155-
it will default to `dev` for `development` and `prod` for `production`.
156-
157-
```bash
158-
# these are equivalent
159-
ng build --target=production --environment=prod
160-
ng build --prod --env=prod
161-
ng build --prod
162-
# and so are these
163-
ng build --target=development --environment=dev
164-
ng build --dev --e=dev
165-
ng build --dev
166-
ng build
167-
```
168-
169-
You can also add your own env files other than `dev` and `prod` by doing the following:
170-
- create a `src/environments/environment.NAME.ts`
171-
- add `{ "NAME": 'src/environments/environment.NAME.ts' }` to the `apps[0].environments` object in `angular-cli.json`
172-
- use them via the `--env=NAME` flag on the build/serve commands.
173-
174-
### Base tag handling in index.html
175-
176-
When building you can modify base tag (`<base href="/">`) in your index.html with `--base-href your-url` option.
177-
178-
```bash
179-
# Sets base tag href to /myUrl/ in your index.html
180-
ng build --base-href /myUrl/
181-
ng build --bh /myUrl/
182-
```
183-
184-
### Bundling
185-
186-
All builds make use of bundling, and using the `--prod` flag in `ng build --prod`
187-
or `ng serve --prod` will also make use of uglifying and tree-shaking functionality.
188-
189-
### Running unit tests
190-
191-
```bash
192-
ng test
193-
```
194-
195-
Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes. You can run tests a single time via `--watch=false` or `--single-run`.
196-
197-
You can run tests with coverage via `--code-coverage`. The coverage report will be in the `coverage/` directory.
198-
199-
### Running end-to-end tests
200-
201-
```bash
202-
ng e2e
203-
```
204-
205-
Before running the tests make sure you are serving the app via `ng serve`.
206-
207-
End-to-end tests are run via [Protractor](https://angular.github.io/protractor/).
208-
209-
### Proxy To Backend
210-
Using the proxying support in webpack's dev server we can highjack certain urls and send them to a backend server.
211-
We do this by passing a file to `--proxy-config`
212-
213-
Say we have a server running on `http://localhost:3000/api` and we want all calls to `http://localhost:4200/api` to go to that server.
214-
215-
We create a file next to projects `package.json` called `proxy.conf.json`
216-
with the content
217-
218-
```json
219-
{
220-
"/api": {
221-
"target": "http://localhost:3000",
222-
"secure": false
223-
}
224-
}
225-
```
226-
227-
You can read more about what options are available here [webpack-dev-server proxy settings](https://webpack.github.io/docs/webpack-dev-server.html#proxy)
228-
229-
and then we edit the `package.json` file's start script to be
230-
231-
```json
232-
"start": "ng serve --proxy-config proxy.conf.json",
233-
```
234-
235-
now run it with `npm start`
236-
237-
238-
### Linting code
239-
240-
You can lint your app code by running `ng lint`.
241-
This will use the `lint` npm script that in generated projects uses `tslint`.
242-
243-
You can modify the these scripts in `package.json` to run whatever tool you prefer.
244-
245-
<!-- DeleteSection1 End here -->
246-
247-
<!-- consider removing autocompletion from readme -->
248-
### Commands autocompletion
249-
250-
To turn on auto completion use the following commands:
251-
252-
For bash:
253-
```bash
254-
ng completion --bash >> ~/.bashrc
255-
source ~/.bashrc
256-
```
257-
258-
For zsh:
259-
```bash
260-
ng completion --zsh >> ~/.zshrc
261-
source ~/.zshrc
262-
```
263-
264-
Windows users using gitbash:
265-
```bash
266-
ng completion --bash >> ~/.bash_profile
267-
source ~/.bash_profile
268-
```
269-
270-
### Project assets
271-
272-
You use the `assets` array in `angular-cli.json` to list files or folders you want to copy as-is when building your project:
273-
```json
274-
"assets": [
275-
"assets",
276-
"favicon.ico"
277-
]
278-
```
279-
280-
<!-- DeleteSection2 Start here to remove upon next release -->
281-
### Global styles
282-
283-
The `styles.css` file allows users to add global styles and supports
284-
[CSS imports](https://developer.mozilla.org/en/docs/Web/CSS/@import).
285-
286-
If the project is created with the `--style=sass` option, this will be a `.sass`
287-
file instead, and the same applies to `scss/less/styl`.
288-
289-
You can add more global styles via the `apps[0].styles` property in `angular-cli.json`.
290-
291-
### CSS Preprocessor integration
292-
293-
Angular CLI supports all major CSS preprocessors:
294-
- sass/scss ([http://sass-lang.com/](http://sass-lang.com/))
295-
- less ([http://lesscss.org/](http://lesscss.org/))
296-
- stylus ([http://stylus-lang.com/](http://stylus-lang.com/))
297-
298-
To use these preprocessors simply add the file to your component's `styleUrls`:
299-
300-
```javascript
301-
@Component({
302-
selector: 'app-root',
303-
templateUrl: './app.component.html',
304-
styleUrls: ['./app.component.scss']
305-
})
306-
export class AppComponent {
307-
title = 'app works!';
308-
}
309-
```
310-
311-
When generating a new project you can also define which extension you want for
312-
style files:
313-
314-
```bash
315-
ng new sassy-project --style=sass
316-
```
317-
318-
Or set the default style on an existing project:
319-
320-
```bash
321-
ng set defaults.styleExt scss
322-
```
323-
324-
### 3rd Party Library Installation
325-
326-
Simply install your library via `npm install lib-name --save` and import it in your code.
327-
328-
If the library does not include typings, you can install them using npm:
329-
330-
```bash
331-
npm install d3 --save
332-
npm install @types/d3 --save-dev
333-
```
334-
335-
If the library doesn't have typings available at `@types/`, you can still use it by
336-
manually adding typings for it:
337-
338-
1. First, create a `typings.d.ts` file in your `src/` folder. This file will be automatically included as global type definition.
339-
340-
2. Then, in `src/typings.d.ts`, add the following code:
341-
342-
```typescript
343-
declare module 'typeless-package';
344-
```
345-
346-
3. Finally, in the component or file that uses the library, add the following code:
347-
348-
```typescript
349-
import * as typelessPackage from 'typeless-package';
350-
typelessPackage.method();
351-
```
352-
353-
Done. Note: you might need or find useful to define more typings for the library that you're trying to use.
354-
355-
### Global Library Installation
356-
357-
Some javascript libraries need to be added to the global scope, and loaded as if
358-
they were in a script tag. We can do this using the `apps[0].scripts` and
359-
`apps[0].styles` properties of `angular-cli.json`.
360-
361-
As an example, to use [Bootstrap 4](http://v4-alpha.getbootstrap.com/) this is
362-
what you need to do:
363-
364-
First install Bootstrap from `npm`:
365-
366-
```bash
367-
npm install bootstrap@next
368-
```
369-
370-
Then add the needed script files to `apps[0].scripts`:
371-
372-
```json
373-
"scripts": [
374-
"../node_modules/jquery/dist/jquery.js",
375-
"../node_modules/tether/dist/js/tether.js",
376-
"../node_modules/bootstrap/dist/js/bootstrap.js"
377-
],
378-
```
379-
380-
Finally add the Bootstrap CSS to the `apps[0].styles` array:
381-
```json
382-
"styles": [
383-
"../node_modules/bootstrap/dist/css/bootstrap.css",
384-
"styles.css"
385-
],
386-
```
387-
388-
Restart `ng serve` if you're running it, and Bootstrap 4 should be working on
389-
your app.
390-
391-
<!-- DeleteSection2 End here -->
392-
393101
### Updating Angular CLI
394102

395103
To update Angular CLI to a new version, you must update both the global package and your project's local package.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Project assets
2+
3+
You use the `assets` array in `angular-cli.json` to list files or folders you want to copy as-is when building your project:
4+
```json
5+
"assets": [
6+
"assets",
7+
"favicon.ico"
8+
]
9+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Autocompletion
2+
3+
To turn on auto completion use the following commands:
4+
5+
For bash:
6+
```bash
7+
ng completion --bash >> ~/.bashrc
8+
source ~/.bashrc
9+
```
10+
11+
For zsh:
12+
```bash
13+
ng completion --zsh >> ~/.zshrc
14+
source ~/.zshrc
15+
```
16+
17+
Windows users using gitbash:
18+
```bash
19+
ng completion --bash >> ~/.bash_profile
20+
source ~/.bash_profile
21+
```

docs/documentation/stories/routing.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Generating a route
2+
3+
The CLI supports routing in several ways:
4+
5+
- We include the `@angular/router` NPM package when creating or initializing a project.
6+
7+
- When you generate a module, you can use the `--routing` option like `ng g module my-module --routing` to create a separate file `my-module-routing.module.ts` to store the module routes.
8+
9+
The file includes an empty `Routes` object that you can fill with routes to different components and/or modules.
10+
11+
The `--routing` option also generates a default component with the same name as the module.
12+
13+
- You can use the `--routing` option with `ng new` to create a `app-routing.module.ts` file when you create or initialize a project.

0 commit comments

Comments
 (0)