From 816d5ba3fd46e59003cec9f01061ff7608c4fb3a Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Tue, 17 Oct 2017 17:36:22 -0700 Subject: [PATCH] docs: NgModule guide prose for CLI (partial) (#19776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also replaces “Angular Module” with “NgModule” wherever that is clarifying. Continue using “module” when qualified as in “feature module”, “root module”, “routing module”, etc. PR Close #19776 --- .../examples/ngmodule/contact.1b.plnkr.json | 2 +- .../examples/ngmodule/contact.2.plnkr.json | 2 +- .../examples/ngmodule/e2e/app.e2e-spec.ts | 4 +- .../examples/ngmodule/pre-shared.3.plnkr.json | 2 +- .../ngmodule/src/app/app-routing.module.3.ts | 9 +- .../ngmodule/src/app/app-routing.module.ts | 23 +- .../ngmodule/src/app/app.component.0.ts | 2 +- .../ngmodule/src/app/app.component.1.ts | 6 +- .../ngmodule/src/app/app.component.1b.ts | 6 +- .../ngmodule/src/app/app.component.2.ts | 6 +- .../ngmodule/src/app/app.component.3.ts | 6 +- .../ngmodule/src/app/app.component.ts | 6 +- .../examples/ngmodule/src/app/app.module.0.ts | 12 +- .../examples/ngmodule/src/app/app.module.1.ts | 14 +- .../ngmodule/src/app/app.module.1b.ts | 27 +- .../examples/ngmodule/src/app/app.module.2.ts | 13 +- .../examples/ngmodule/src/app/app.module.3.ts | 21 +- .../examples/ngmodule/src/app/app.module.ts | 7 +- ...tive.ts => contact-highlight.directive.ts} | 12 +- .../app/contact/contact-routing.module.3.ts | 10 +- .../src/app/contact/contact-routing.module.ts | 10 +- .../src/app/contact/contact.component.3.ts | 2 +- .../src/app/contact/contact.component.css | 3 + .../src/app/contact/contact.component.html | 24 +- .../src/app/contact/contact.component.ts | 2 +- .../src/app/contact/contact.module.0.ts | 11 + .../src/app/contact/contact.module.2.ts | 25 +- .../src/app/contact/contact.module.3.ts | 32 +- .../src/app/contact/contact.module.ts | 5 +- .../src/app/contact/contact.service.ts | 27 +- .../src/app/core/title.component.html | 2 +- .../ngmodule/src/app/core/title.component.ts | 1 - .../src/app/crisis/crisis-list.component.ts | 17 +- .../ngmodule/src/app/crisis/crisis.service.ts | 24 +- .../src/app/hero/hero-detail.component.ts | 2 +- .../src/app/hero/hero-list.component.ts | 11 +- .../ngmodule/src/app/hero/hero.module.3.ts | 3 +- .../ngmodule/src/app/hero/hero.service.ts | 25 +- .../ngmodule/src/app/highlight.directive.ts | 9 +- .../src/app/shared/highlight.directive.ts | 3 +- .../ngmodule/src/app/title.component.html | 2 +- .../ngmodule/src/app/title.component.ts | 7 +- aio/content/guide/aot-compiler.md | 2 +- aio/content/guide/dependency-injection.md | 2 +- aio/content/guide/ngmodule-faq.md | 518 ++---- aio/content/guide/ngmodule.md | 1626 ++++++++--------- aio/content/navigation.json | 6 +- 47 files changed, 1170 insertions(+), 1421 deletions(-) rename aio/content/examples/ngmodule/src/app/contact/{highlight.directive.ts => contact-highlight.directive.ts} (61%) create mode 100644 aio/content/examples/ngmodule/src/app/contact/contact.module.0.ts diff --git a/aio/content/examples/ngmodule/contact.1b.plnkr.json b/aio/content/examples/ngmodule/contact.1b.plnkr.json index 0f61c91f75..1f2122de63 100644 --- a/aio/content/examples/ngmodule/contact.1b.plnkr.json +++ b/aio/content/examples/ngmodule/contact.1b.plnkr.json @@ -14,7 +14,7 @@ "app/contact/contact.component.html", "app/contact/contact.component.3.ts", "app/contact/contact.service.ts", - "app/contact/highlight.directive.ts", + "app/contact/contact-highlight.directive.ts", "main.1b.ts", "styles.css", diff --git a/aio/content/examples/ngmodule/contact.2.plnkr.json b/aio/content/examples/ngmodule/contact.2.plnkr.json index 6555b76dcd..9c844831c7 100644 --- a/aio/content/examples/ngmodule/contact.2.plnkr.json +++ b/aio/content/examples/ngmodule/contact.2.plnkr.json @@ -16,7 +16,7 @@ "app/contact/awesome.pipe.ts", "app/contact/contact.component.3.ts", "app/contact/contact.module.2.ts", - "app/contact/highlight.directive.ts", + "app/contact/contact-highlight.directive.ts", "main.2.ts", "styles.css", diff --git a/aio/content/examples/ngmodule/e2e/app.e2e-spec.ts b/aio/content/examples/ngmodule/e2e/app.e2e-spec.ts index e3370efd1b..72d1ca9214 100644 --- a/aio/content/examples/ngmodule/e2e/app.e2e-spec.ts +++ b/aio/content/examples/ngmodule/e2e/app.e2e-spec.ts @@ -15,7 +15,7 @@ describe('NgModule', function () { return { title: element.all(by.tagName('h1')).get(0), - subtitle: element.all(by.css('app-title p i')).get(0), + welcome: element.all(by.css('app-title p i')).get(0), contactButton: buttons.get(0), crisisButton: buttons.get(1), heroesButton: buttons.get(2) @@ -67,7 +67,7 @@ describe('NgModule', function () { it('should welcome us', function () { const commons = getCommonsSectionStruct(); - expect(commons.subtitle.getText()).toBe('Welcome, ' + (name || 'Sherlock Holmes')); + expect(commons.welcome.getText()).toBe('Welcome, ' + (name || 'Sherlock Holmes')); }); }; } diff --git a/aio/content/examples/ngmodule/pre-shared.3.plnkr.json b/aio/content/examples/ngmodule/pre-shared.3.plnkr.json index 9747801604..97bdd8dfd9 100644 --- a/aio/content/examples/ngmodule/pre-shared.3.plnkr.json +++ b/aio/content/examples/ngmodule/pre-shared.3.plnkr.json @@ -19,7 +19,7 @@ "app/contact/contact.component.3.ts", "app/contact/contact.module.3.ts", "app/contact/contact-routing.module.3.ts", - "app/contact/highlight.directive.ts", + "app/contact/contact-highlight.directive.ts", "app/crisis/*.ts", diff --git a/aio/content/examples/ngmodule/src/app/app-routing.module.3.ts b/aio/content/examples/ngmodule/src/app/app-routing.module.3.ts index 1d53b708f8..f3c68f5050 100644 --- a/aio/content/examples/ngmodule/src/app/app-routing.module.3.ts +++ b/aio/content/examples/ngmodule/src/app/app-routing.module.3.ts @@ -1,14 +1,19 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -export const routes: Routes = [ +import { ContactModule } from './contact/contact.module.3'; + +const routes: Routes = [ { path: '', redirectTo: 'contact', pathMatch: 'full'}, { path: 'crisis', loadChildren: 'app/crisis/crisis.module#CrisisModule' }, { path: 'heroes', loadChildren: 'app/hero/hero.module.3#HeroModule' } ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [ + ContactModule, + RouterModule.forRoot(routes) + ], exports: [RouterModule] }) export class AppRoutingModule {} diff --git a/aio/content/examples/ngmodule/src/app/app-routing.module.ts b/aio/content/examples/ngmodule/src/app/app-routing.module.ts index c753dcd488..4ce7438bc4 100644 --- a/aio/content/examples/ngmodule/src/app/app-routing.module.ts +++ b/aio/content/examples/ngmodule/src/app/app-routing.module.ts @@ -2,18 +2,29 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -export const routes: Routes = [ +import { ContactModule } from './contact/contact.module'; + +// #docregion routes +const routes: Routes = [ { path: '', redirectTo: 'contact', pathMatch: 'full'}, -// #docregion lazy-routes + // #docregion lazy-routes { path: 'crisis', loadChildren: 'app/crisis/crisis.module#CrisisModule' }, { path: 'heroes', loadChildren: 'app/hero/hero.module#HeroModule' } -// #enddocregion lazy-routes + // #enddocregion lazy-routes ]; +// #enddocregion routes -// #docregion forRoot @NgModule({ - imports: [RouterModule.forRoot(routes)], + // #docregion imports + imports: [ + ContactModule, + // #docregion forRoot + RouterModule.forRoot(routes), + // #enddocregion forRoot + ], + // #enddocregion imports + // #docregion exports exports: [RouterModule] + // #enddocregion exports }) export class AppRoutingModule {} -// #enddocregion forRoot diff --git a/aio/content/examples/ngmodule/src/app/app.component.0.ts b/aio/content/examples/ngmodule/src/app/app.component.0.ts index 50243d3fce..9aac868764 100644 --- a/aio/content/examples/ngmodule/src/app/app.component.0.ts +++ b/aio/content/examples/ngmodule/src/app/app.component.0.ts @@ -6,5 +6,5 @@ import { Component } from '@angular/core'; template: '

{{title}}

', }) export class AppComponent { - title = 'Minimal NgModule'; + title = 'Angular Modules'; } diff --git a/aio/content/examples/ngmodule/src/app/app.component.1.ts b/aio/content/examples/ngmodule/src/app/app.component.1.ts index a0b22b8270..6cdf540f0e 100644 --- a/aio/content/examples/ngmodule/src/app/app.component.1.ts +++ b/aio/content/examples/ngmodule/src/app/app.component.1.ts @@ -11,9 +11,7 @@ import { Component } from '@angular/core'; // #enddocregion template */ // #docregion - template: '' + template: '' }) -export class AppComponent { - subtitle = '(v1)'; -} +export class AppComponent {} // #enddocregion diff --git a/aio/content/examples/ngmodule/src/app/app.component.1b.ts b/aio/content/examples/ngmodule/src/app/app.component.1b.ts index 48447bb966..36e3005e0a 100644 --- a/aio/content/examples/ngmodule/src/app/app.component.1b.ts +++ b/aio/content/examples/ngmodule/src/app/app.component.1b.ts @@ -5,11 +5,9 @@ import { Component } from '@angular/core'; selector: 'app-root', // #docregion template template: ` - + ` // #enddocregion template }) -export class AppComponent { - subtitle = '(v1)'; -} +export class AppComponent {} diff --git a/aio/content/examples/ngmodule/src/app/app.component.2.ts b/aio/content/examples/ngmodule/src/app/app.component.2.ts index 4c6d3ba113..f28e4526e9 100644 --- a/aio/content/examples/ngmodule/src/app/app.component.2.ts +++ b/aio/content/examples/ngmodule/src/app/app.component.2.ts @@ -3,10 +3,8 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` - + ` }) -export class AppComponent { - subtitle = '(v2)'; -} +export class AppComponent {} diff --git a/aio/content/examples/ngmodule/src/app/app.component.3.ts b/aio/content/examples/ngmodule/src/app/app.component.3.ts index e6c9a93754..cab904e656 100644 --- a/aio/content/examples/ngmodule/src/app/app.component.3.ts +++ b/aio/content/examples/ngmodule/src/app/app.component.3.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; selector: 'app-root', // #docregion template template: ` - +