Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 7fe1345

Browse files
committed
docs(quickstart): removed AppModule; created dynamically
1 parent 7a6c2e7 commit 7fe1345

File tree

10 files changed

+84
-93
lines changed

10 files changed

+84
-93
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
selector: 'my-app',
6+
template: `<h1>Hello {{name}}</h1>`
7+
})
8+
export class AppComponent { name = 'Angular'; }

public/docs/_examples/quickstart/ts/app/app.module.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
// #docregion
2-
import { Component, NgModule } from '@angular/core';
3-
import { BrowserModule } from '@angular/platform-browser';
4-
5-
@Component({
6-
selector: 'my-app',
7-
template: `<h1>Hello {{title}}</h1>`
8-
})
9-
class AppComponent { title = 'Angular'; }
2+
import { NgModule } from '@angular/core';
3+
import { BrowserModule } from '@angular/platform-browser';
4+
import { AppComponent } from './app.component';
105

116
@NgModule({
127
imports: [ BrowserModule ],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<!-- #docregion -->
3+
<html>
4+
<head>
5+
<title>Hello Angular</title>
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<style>
9+
body {color:#369;font-family: Arial,Helvetica,sans-serif;}
10+
</style>
11+
12+
<!-- Polyfills for older browsers -->
13+
<script src="node_modules/core-js/client/shim.min.js"></script>
14+
15+
<script src="node_modules/zone.js/dist/zone.js"></script>
16+
<script src="node_modules/reflect-metadata/Reflect.js"></script>
17+
<script src="node_modules/systemjs/dist/system.src.js"></script>
18+
19+
<!-- #docregion no-app-module-->
20+
<script> window.noAppModule = true; </script>
21+
<!-- #enddocregion no-app-module-->
22+
23+
<script src="systemjs.config.js"></script>
24+
<script>
25+
System.import('app').catch(function(err){ console.error(err); });
26+
</script>
27+
</head>
28+
29+
<body>
30+
<!-- #docregion my-app-->
31+
<my-app><!-- content managed by Angular --></my-app>
32+
<!-- #enddocregion my-app-->
33+
</body>
34+
35+
</html>
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<!DOCTYPE html>
2-
<!-- #docregion -->
32
<html>
43
<head>
54
<title>Hello Angular</title>
65
<meta charset="UTF-8">
76
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<link rel="stylesheet" href="styles.css">
97
<style>
108
body {color:#369;font-family: Arial,Helvetica,sans-serif;}
119
</style>
1210

13-
<!-- #docregion polyfills -->
14-
<!-- Polyfill for older browsers -->
11+
<!-- Polyfills for older browsers -->
1512
<script src="node_modules/core-js/client/shim.min.js"></script>
16-
<!-- #enddocregion polyfills -->
1713

1814
<script src="node_modules/zone.js/dist/zone.js"></script>
1915
<script src="node_modules/reflect-metadata/Reflect.js"></script>
@@ -25,9 +21,7 @@
2521
</head>
2622

2723
<body>
28-
<!-- #docregion my-app-->
2924
<my-app><!-- content managed by Angular --></my-app>
30-
<!-- #enddocregion my-app-->
3125
</body>
3226

3327
</html>

public/docs/_examples/quickstart/ts/package.1.json

-41
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"description": "QuickStart",
33
"files": [
4-
"app/app.module.ts",
5-
"index.html"
4+
"app/app.component.ts",
5+
"index.1.html"
66
],
7-
"open": "app/app.module.ts",
7+
"main": "index.1.html",
8+
"open": "app/app.component.ts",
89
"tags": ["quickstart"]
910
}

public/docs/_examples/setup/ts/app/app.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Component } from '@angular/core';
33

44
@Component({
5-
template: `<h1>Hello {{title}}</h1>`,
6-
selector: 'my-app'
5+
selector: 'my-app',
6+
template: `<h1>Hello {{name}}</h1>`
77
})
8-
export class AppComponent { title = 'Angular'; }
8+
export class AppComponent { name = 'Angular'; }

public/docs/ts/latest/guide/setup.jade

+6-5
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ code-example(language="sh" class="code-shell").
7676
app/main.ts
7777
`)(format='.')
7878
:marked
79-
The guides and cookbooks in these page expect you to have re-factored the [QuickStart](../quickstart.html "Angular QuickStart") sample
80-
into these three files. It's wise to do so.
79+
The [QuickStart](../quickstart.html "Angular QuickStart") sample only showed the `AppComponent` file.
80+
The documentation guides and cookbooks expect you to have defined these three files explicitly.
8181
Each file has a distinct purpose and evolves independently as the application grows.
8282

8383
style td, th {vertical-align: top}
@@ -92,13 +92,14 @@ table(width="100%")
9292
td
9393
:marked
9494
The `AppComponent` currently displays the "Hello Angular" header.
95-
It is the root of what will become a tree of nested components.
95+
It is the **root** of what will become a tree of nested components.
9696
tr
9797
td <code>app.module.ts</code>
9898
td
9999
:marked
100-
The `AppModule` tells Angular how to assemble the application.
101-
There will soon be more than the `AppComponent` to talk about.
100+
The `AppModule` is the **root module** that tells Angular how to assemble the application.
101+
Right now it declares only the `AppComponent`.
102+
Soon there will be more components to talk about.
102103
tr
103104
td <code>main.ts</code>
104105
td

public/docs/ts/latest/quickstart.jade

+23-25
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,38 @@ block includes
77
Just open it and follow along with the documentation.
88
If you'd rather develop in a local environment, learn how on the [Setup](guide/setup.html) page.
99

10-
Here's a super-simple Angular application:
10+
Angular applications are made of _components_.
11+
A _component_ is the combination of an HTML template and a component class that controls a portion of the screen.
12+
Here's a super-simple Angular component, written in [TypeScript](#typescript):
1113

12-
+makeExample('app/app.module.ts','','app/app.module.ts')(format='.')
14+
+makeExample('app/app.component.ts','','app/app.component.ts')(format='.')
1315
:marked
14-
### _AppComponent_
15-
Angular applications are made of _components_.
16-
A _component_ is the combination of an HTML template and JavaScript class that controls a portion of the screen.
16+
The `@Component` [_decorator_](glossary.html#decorator '"Decorator" explained') function takes a _metadata_ object that
17+
describes how the HTML template and component class work together.
1718

18-
According to the `selector`, this `AppComponent` displays its content inside a custom `<my-app>` tag in the `index.html`.
19-
+makeExample('index.html','my-app','index.html (body)')(format='.')
19+
The `selector` property tells Angular to display the component inside a custom `<my-app>` tag in the `index.html`.
20+
+makeExample('index.1.html','my-app','index.html (body)')(format='.')
2021
:marked
21-
The `AppComponent` template renders the message, "Hello Angular", inside an `<h1>` header.
22-
The word "Angular" appears thanks to an [interpolation binding](guide/displaying-data.html)
23-
that projects the component's `title` property into the `{{title}}` slot.
24-
Change the property value from `'Angular'` to `'World'` and see what happens.
22+
The `template` property defines a message inside an `<h1>` header.
23+
The message starts with "Hello" and ends with `{{name}}`
24+
which is an Angular [interpolation binding](guide/displaying-data.html) expression.
25+
At runtime, Angular replaces `{{name}}` with the value of the component's `name` property.
26+
Change the component class's `name` property from `'Angular'` to `'World'` and see what happens.
2527

2628
Binding is one of many Angular features you'll discover in this documentation.
29+
30+
.l-sub-section
31+
:marked
32+
### Next step
33+
Start [learning Angular](guide/learning-angular.html).
2734

28-
### _AppModule_
29-
The `AppModule` tells Angular<br>
30-
&nbsp;&nbsp;***what you need*** &mdash; _imports_ the `BrowserModule` to run the application in the browser.<br>
31-
&nbsp;&nbsp;***what you created*** &mdash; _declares_ the `AppComponent`.<br>
32-
&nbsp;&nbsp;***what to show*** &mdash; _bootstrap_ the `AppComponent` onto the `index.html` web page within the `<my-app>` tag.
33-
34-
You'll find more _live code examples_ like this one on almost every documentation page.
35-
36-
# TypeScript
35+
.l-main-section
36+
a#typescript
37+
:marked
38+
## TypeScript
3739
This example is written in <a href="http://www.typescriptlang.org/" target="_blank" title="TypeScript">TypeScript</a>,
3840
a strongly-typed, super-set of the latest JavaScript.
3941
TypeScript turns into JavaScript that runs on any modern browser.
4042
Most developers find it delightful which is why most Angular developers write applications in TypeScript.
4143
You can write your application in [other versions of JavaScript](cookbook/ts-to-js.html) if you prefer.
42-
43-
.l-sub-section
44-
:marked
45-
### Next step
46-
Start [learning Angular](guide/learning-angular.html).
44+

tools/plunker-builder/indexHtmlTranslator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var _rxRules = {
2121
},
2222
systemjs: {
2323
from: /<script src="systemjs.config.js"><\/script>/,
24-
to: '<script src="https://cdn.rawgit.com/angular/angular.io/74ef87f/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>'
24+
to: '<script src="https://cdn.rawgit.com/angular/angular.io/f2daab7/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>'
2525
},
2626
// Clear script like this:
2727
// <script>

0 commit comments

Comments
 (0)