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

Commit 5b294e3

Browse files
thelgevoldwardbell
authored andcommitted
docs(cb-aot): add missing module.id to sample (#2908)
1 parent 1d5e7c3 commit 5b294e3

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

public/docs/_examples/cb-aot-compiler/ts/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// #docregion
2-
// #docregion
32
import { Component } from '@angular/core';
43

54
@Component({
5+
moduleId: module.id,
66
selector: 'my-app',
77
templateUrl: 'app.component.html'
88
})

public/docs/_examples/cb-aot-compiler/ts/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
<script src="node_modules/core-js/client/shim.min.js"></script>
1111
<script src="node_modules/zone.js/dist/zone.js"></script>
12-
12+
<!-- #docregion moduleId -->
13+
<script>window.module = 'aot';</script>
14+
<!-- #enddocregion moduleId -->
1315
</head>
1416

1517
<!-- #docregion bundle -->

public/docs/ts/latest/cookbook/aot-compiler.jade

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ code-example(format='.').
129129
The `"skipMetadataEmit" : true` property prevents the compiler from generating metadata files with the compiled application.
130130
Metadata files are not necessary when targeting TypeScript files, so there is no reason to include them.
131131

132+
:marked
133+
***Component-relative Template URLS***
134+
135+
The AoT compiler requires that `@Component` URLS for external templates and css files be _component-relative_.
136+
That means that the value of `@Component.templateUrl` is a URL value _relative_ to the component class file.
137+
For example, an `'app.component.html'` URL means that the template file is a sibling of its companion `app.component.ts` file.
138+
139+
While JiT app URLs are more flexible, stick with _component-relative_ URLs for compatibility with AoT compilation.
140+
141+
JiT-compiled applications that use the SystemJS loader and _component-relative_ URLs *must set the* `@Component.moduleId` *property to* `module.id`.
142+
The `module` object is undefined when an AoT-compiled app runs.
143+
The app fails with a null reference error unless you assign a global `module` value in the `index.html` like this:
144+
+makeExample('cb-aot-compiler/ts/index.html','moduleId')(format='.')
145+
.l-sub-section
146+
:marked
147+
Setting a global `module` is a temporary expedient.
148+
149+
:marked
132150
### Compiling the application
133151

134152
Initiate AoT compilation from the command line using the previously installed `ngc` compiler by executing:
@@ -376,22 +394,6 @@ a#toh
376394
app/main.ts (JiT)`
377395
)
378396

379-
:marked
380-
***Component-relative Template URLS***
381-
382-
The AoT compiler requires that `@Component` URLS for external templates and css files be _component-relative_.
383-
That means that the value of `@Component.templateUrl` is a URL value _relative_ to the component class file.
384-
For example, a `'hero.component.html'` URL means that the template file is a sibling of its companion `hero.component.ts` file.
385-
386-
While JiT app URLs are more flexible, stick with _component-relative_ URLs for compatibility with AoT compilation.
387-
388-
JiT-compiled applications that use the SystemJS loader and _component-relative_ URLs *must set the* `@Component.moduleId` *property to* `module.id`.
389-
The `module` object is undefined when an AoT-compiled app runs.
390-
The app fails with a null reference error unless you assign a global `module` value in the `index.html` like this:
391-
+makeExample('toh-6/ts/aot/index.html','moduleId')(format='.')
392-
.l-sub-section
393-
:marked
394-
Setting a global `module` is a temporary expedient.
395397
:marked
396398
***TypeScript configuration***
397399

0 commit comments

Comments
 (0)