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

Commit b2f4148

Browse files
authored
chore(quickstart): restore app.module and main (#3166)
We seemed to create more confusion by omitting app.module (and main) in QS than we gained in simplicity of QS Every other example requires these files. This PR restores them to QS _but doesn't talk about them_ in QS, leaving _that_ to the Setup guide.
1 parent dc4da63 commit b2f4148

File tree

11 files changed

+50
-166
lines changed

11 files changed

+50
-166
lines changed

public/docs/_examples/_boilerplate/src/systemjs.config.web.build.js

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -79,58 +79,6 @@
7979
}
8080
});
8181

82-
if (global.autoBootstrap) { bootstrap(); }
83-
84-
// Bootstrap with a default `AppModule`
85-
// ignore an `app/app.module.ts` and `app/main.ts`, even if present
86-
// This function exists primarily (exclusively?) for the QuickStart
87-
function bootstrap() {
88-
console.log('Auto-bootstrapping');
89-
90-
// Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
91-
System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));
92-
93-
// bootstrap and launch the app (equivalent to standard main.ts)
94-
Promise.all([
95-
System.import('@angular/platform-browser-dynamic'),
96-
getAppModule()
97-
])
98-
.then(function (imports) {
99-
var platform = imports[0];
100-
var app = imports[1];
101-
platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
102-
})
103-
.catch(function(err){ console.error(err); });
104-
}
105-
106-
// Make the default AppModule
107-
// returns a promise for the AppModule
108-
function getAppModule() {
109-
console.log('Making a bare-bones, default AppModule');
110-
111-
return Promise.all([
112-
System.import('@angular/core'),
113-
System.import('@angular/platform-browser'),
114-
System.import('app/app.component')
115-
])
116-
.then(function (imports) {
117-
118-
var core = imports[0];
119-
var browser = imports[1];
120-
var appComp = imports[2].AppComponent;
121-
122-
var AppModule = function() {}
123-
124-
AppModule.annotations = [
125-
new core.NgModule({
126-
imports: [ browser.BrowserModule ],
127-
declarations: [ appComp ],
128-
bootstrap: [ appComp ]
129-
})
130-
]
131-
return {AppModule: AppModule};
132-
})
133-
}
13482
})(this);
13583

13684
/*

public/docs/_examples/_boilerplate/src/systemjs.config.web.js

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -66,58 +66,6 @@
6666
}
6767
});
6868

69-
if (global.autoBootstrap) { bootstrap(); }
70-
71-
// Bootstrap with a default `AppModule`
72-
// ignore an `app/app.module.ts` and `app/main.ts`, even if present
73-
// This function exists primarily (exclusively?) for the QuickStart
74-
function bootstrap() {
75-
console.log('Auto-bootstrapping');
76-
77-
// Stub out `app/main.ts` so System.import('app') doesn't fail if called in the index.html
78-
System.set(System.normalizeSync('app/main.ts'), System.newModule({ }));
79-
80-
// bootstrap and launch the app (equivalent to standard main.ts)
81-
Promise.all([
82-
System.import('@angular/platform-browser-dynamic'),
83-
getAppModule()
84-
])
85-
.then(function (imports) {
86-
var platform = imports[0];
87-
var app = imports[1];
88-
platform.platformBrowserDynamic().bootstrapModule(app.AppModule);
89-
})
90-
.catch(function(err){ console.error(err); });
91-
}
92-
93-
// Make the default AppModule
94-
// returns a promise for the AppModule
95-
function getAppModule() {
96-
console.log('Making a bare-bones, default AppModule');
97-
98-
return Promise.all([
99-
System.import('@angular/core'),
100-
System.import('@angular/platform-browser'),
101-
System.import('app/app.component')
102-
])
103-
.then(function (imports) {
104-
105-
var core = imports[0];
106-
var browser = imports[1];
107-
var appComp = imports[2].AppComponent;
108-
109-
var AppModule = function() {}
110-
111-
AppModule.annotations = [
112-
new core.NgModule({
113-
imports: [ browser.BrowserModule ],
114-
declarations: [ appComp ],
115-
bootstrap: [ appComp ]
116-
})
117-
]
118-
return {AppModule: AppModule};
119-
})
120-
}
12169
})(this);
12270

12371
/*

public/docs/_examples/quickstart/ts/plnkr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"basePath": "src/",
44
"files": [
55
"app/app.component.ts",
6+
"app/app.module.ts",
7+
"main.ts",
68
"index.html"
79
],
810
"open": "app/app.component.ts",

public/docs/_examples/quickstart/ts/src/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
<script src="node_modules/zone.js/dist/zone.js"></script>
1818
<script src="node_modules/systemjs/dist/system.src.js"></script>
19-
20-
<!-- #docregion autobootstrap-->
21-
<script> window.autoBootstrap = true; </script>
22-
<!-- #enddocregion autobootstrap-->
23-
2419
<script src="systemjs.config.js"></script>
2520
<script>
2621
System.import('main.js').catch(function(err){ console.error(err); });

public/docs/ts/latest/cli-quickstart.jade

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ include _util-fns
88
that can create a project, add files, and perform a variety of on-going development tasks such
99
as testing, bundling, and deployment.
1010

11-
Our goal in this CLI QuickStart chapter is to build and run a super-simple Angular
11+
The goal in this CLI QuickStart chapter is to build and run a super-simple Angular
1212
application in TypeScript, using Angular-CLI
1313
while adhering to the [Style Guide](./guide/style-guide.html) recommendations that
1414
benefit _every_ Angular project.
1515

1616
By the end of the chapter, you'll have a basic understanding of development with the CLI
17-
and a foundation for both these documentation samples and our real world applications.
17+
and a foundation for both these documentation samples and for real world applications.
1818

1919
You'll pursue these ends in the following high-level steps:
2020

@@ -27,7 +27,7 @@ include _util-fns
2727
.l-main-section
2828
h2#devenv Step 1. Set up the Development Environment
2929
:marked
30-
You need to set up our development environment before you can do anything.
30+
You need to set up your development environment before you can do anything.
3131

3232
Install **[Node.js® and npm](https://nodejs.org/en/download/)**
3333
if they are not already on your machine.
@@ -68,18 +68,18 @@ code-example(language="sh" class="code-shell").
6868
ng serve
6969

7070
:marked
71-
The `ng serve` command launches the server, watches our files,
72-
and rebuilds the app as you make changes to the files.
71+
The `ng serve` command launches the server, watches your files,
72+
and rebuilds the app as you make changes to those files.
7373

74-
Open a browser on `http://localhost:4200/`; the app greets us with a message:
74+
Open a browser on `http://localhost:4200/`; the app greets you with a message:
7575

7676
figure.image-display
77-
img(src='/resources/images/devguide/cli-quickstart/app-works.png' alt="Our app works!")
77+
img(src='/resources/images/devguide/cli-quickstart/app-works.png' alt="The app works!")
7878

7979
.l-main-section
80-
h2#first-component Step 4: Edit our first Angular component
80+
h2#first-component Step 4: Edit your first Angular component
8181
:marked
82-
The CLI created our first Angular component for us.
82+
The CLI created the first Angular component for you.
8383
This is the _root component_ and it is named `app-root`.
8484
You can find it in `./src/app/app.component.ts`.
8585

@@ -91,7 +91,7 @@ h2#first-component Step 4: Edit our first Angular component
9191
:marked
9292
The browser reloads automatically and we see the revised title. That's nice, but we can make it look better.
9393

94-
Open `src/app/cli-quickstart.component.css` and give our component some style
94+
Open `src/app/cli-quickstart.component.css` and give the component some style
9595

9696
+makeExample('cli-quickstart/ts/src/app/app.component.css', null, 'src/app/app.component.css')(format=".")
9797

@@ -175,10 +175,9 @@ table(width="100%")
175175
td <code>app/app.module.ts</code>
176176
td
177177
:marked
178-
Defines `AppModule`, the [root module](guide/appmodule.html "AppModule: the root module")
179-
that tells Angular how to assemble the application.
180-
Right now it declares only the `AppComponent`.
181-
Soon there will be more components to declare.
178+
Defines `AppModule`, the [root module](guide/appmodule.html "AppModule: the root module") that tells Angular how to assemble the application.
179+
Right now it declares only the `AppComponent`.
180+
Soon there will be more components to declare.
182181
tr
183182
td <code>assets/*</code>
184183
td
@@ -215,9 +214,8 @@ table(width="100%")
215214
td
216215
:marked
217216
The main entry point for your app.
218-
Compiles the application with the [JiT compiler](glossary.html#jit)
219-
and [bootstraps](guide/appmodule.html#main "bootstrap the application")
220-
the application to run in the browser.
217+
Compiles the application with the [JIT compiler](glossary.html#jit)
218+
and bootstraps the application's root module (`AppModule`) to run in the browser.
221219
You can also use the [AoT compiler](glossary.html#ahead-of-time-aot-compilation)
222220
without changing any code by passing on `--aot` to `ng build` or `ng serve`.
223221
tr

public/docs/ts/latest/guide/_data.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"basics": true
3434
},
3535

36-
3736
"appmodule": {
3837
"title": "AppModule: the root module",
3938
"navTitle": "The Root Module",

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ include ../_util-fns
2222
* **_declarations_** &mdash; the application's lone component, which is also ...
2323
* **_bootstrap_** &mdash; the _root_ component that Angular creates and inserts into the `index.html` host web page.
2424

25-
The [Angular Modules (NgModules)](ngmodule.html) guide dives deeply into the details of Angular modules.
25+
The [Angular Modules (NgModule)](ngmodule.html) guide dives deeply into the details of Angular modules.
2626
All you need to know at the moment is a few basics about these three properties.
2727

2828
a#imports
@@ -43,35 +43,39 @@ a#imports
4343

4444
.alert.is-important
4545
:marked
46-
**Only `NgModule` classes** go in the `imports` array. Don't put any other kind of class in `imports`.
46+
**Only `NgModule` classes** go in the `imports` array. Do not put any other kind of class in `imports`.
4747

4848
.l-sub-section
4949
:marked
50-
Don't confuse the `import` statements at the top of the file with the Angular module's `imports` array.
51-
They have different jobs.
50+
The `import` statements at the top of the file and the Angular module's `imports` array
51+
are unrelated and have completely different jobs.
5252

5353
The _JavaScript_ `import` statements give you access to symbols _exported_ by other files
54-
so you can reference them within _this_ file.
54+
so you can reference them within _this_ file.
55+
You add `import` statements to almost every application file.
5556
They have nothing to do with Angular and Angular knows nothing about them.
5657

57-
The _module's_ `imports` array tells Angular about specific Angular modules &mdash; classes decorated with `@NgModule` &mdash;
58+
The _module's_ `imports` array appears _exclusively_ in the `@NgModule` metadata object.
59+
It tells Angular about specific _other_ Angular modules &mdash; all of them classes decorated with `@NgModule` &mdash;
5860
that the application needs to function properly.
5961
a#declarations
6062
:marked
6163
### The _declarations_ array
6264

63-
You must declare _every_ component in one (and _only one_) `NgModule` class.
6465
You tell Angular which components belong to the `AppModule` by listing it in the module's `declarations` array.
6566
As you create more components, you'll add them to `declarations`.
6667

68+
You must declare _every_ component in an `NgModule` class.
69+
If you use a component without declaring it, you'll see a clear error message in the browser console.
70+
6771
You'll learn to create two other kinds of classes &mdash;
6872
[directives](attribute-directives.html) and [pipes](pipes.html) &mdash;
6973
that you must also add to the `declarations` array.
7074

7175
.alert.is-important
7276
:marked
7377
**Only _declarables_** &mdash; _components_, _directives_ and _pipes_ &mdash; belong in the `declarations` array.
74-
Don't put any other kind of class in `declarations`; _not_ `NgModule` classes, _not_ service classes, _not_ model classes.
78+
Do not put any other kind of class in `declarations`; _not_ `NgModule` classes, _not_ service classes, _not_ model classes.
7579

7680
a#bootstrap-array
7781
:marked
@@ -121,18 +125,13 @@ l-main-section
121125

122126
This file is very stable. Once you've set it up, you may never change it again.
123127

124-
a#quickstart-appmodule
125128
l-main-section
126129
:marked
127-
## QuickStart's _AppModule_
128-
Every Angular application must have a root `NgModule`, even the [QuickStart](../quickstart.html).
129-
You didn't see it but it was there.
130-
131-
A script in the `index.html` generated a hidden `AppModule` and bootstrapped it for you
132-
so you could focus on the `AppComponent` and discover the _essential Angular_ more quickly.
130+
## More about Angular Modules
133131

134-
If you're feeling adventurous, add your own `AppModule` and `main.ts` to the
135-
live code in the _QuickStart_ plunker.
132+
Your initial app has only a single module, the _root_ module.
133+
As your app grows, you'll consider subdividing it into multiple "feature" modules,
134+
so of which can be loaded later ("lazy loaded") if and when the user chooses
135+
to visit those features.
136136

137-
Remove the following `<script>` tag from the `index.html` and see _your_ work in action.
138-
+makeExample('quickstart/ts/src/index.html','autobootstrap','Remove this script tag from "index.html"')(format='.')
137+
When you're ready to explore these possibilities, visit the [Angular Modules (NgModule)](ngmodule.html) guide.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ block angular-modules
5757

5858
<br class="l-clear-both"><br>
5959
:marked
60-
Every Angular app has at least one Angular module class, [the _root module_](appmodule.html "AppModule: the root module"),
60+
Every Angular app has at least one Angular module class, [the _root module_](appmodule.html "AppModule: the root module"),
6161
conventionally named `AppModule`.
6262

6363
While the _root module_ may be the only module in a small application, most apps have many more

public/docs/ts/latest/guide/learning-angular.jade

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ figure
1818
a sensible project structure, data binding, master/detail, services, dependency injection, navigation, and remote data access.
1919

2020
1. <a id="architecture"></a>Read the [Architecture](architecture.html) overview for the big picture.
21-
<li if-docs="ts"><p>
22-
[The Root Module](appmodule.html) introduces the `NgModule` class that tells Angular how to compile and run your application.
23-
</p></li>
21+
22+
1. [The Root Module](appmodule.html) introduces the `NgModule` class that tells Angular how to compile and run your application.
2423

2524
1. [Displaying Data](displaying-data.html) shows how data binding puts component property values on screen.
2625

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ block includes
1414
It may add service providers to the application dependency injectors.
1515
And there are many more options covered here.
1616

17-
[The Root Module](appmodule.html) page introduced Angular Modules and the essentials
17+
[The Root Module](appmodule.html) guide introduced Angular Modules and the essentials
1818
of creating and maintaining a single _root_ `AppModule` for the entire application.
1919
Read that first.
2020

21-
This page goes into much greater depth as this extensive table of contents reveals.
21+
This page goes into Angular modules in much greater depth.
2222

2323
## Table of Contents
2424
* [Angular modularity](#angular-modularity "Add structure to the app with NgModule")

0 commit comments

Comments
 (0)