Skip to content

Commit f255801

Browse files
committed
fixed load bundles
1 parent 15bb459 commit f255801

File tree

14 files changed

+18927
-29
lines changed

14 files changed

+18927
-29
lines changed

apps/codelab/src/app/codelabs/angular/forms/samples/basic/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import * as code from './code';
55

66
class MyResourceLoader extends ResourceLoader {
77
get(url: string): Promise<string> {
8+
let searchString = url.replace(/[\/\.-]/gi, '_');
9+
10+
// TODO(sancheez): fix load templates with relative url (relative url in Component)
11+
if (url.startsWith(".")) {
12+
searchString = searchString.substring(2);
13+
}
14+
815
const templateId = Object.keys(code).find((key) =>
9-
key.includes(url.replace(/[\/\.-]/gi, '_'))
16+
key.includes(searchString)
1017
);
1118
const template = code[templateId];
1219
if (!template) {

apps/codelab/src/app/codelabs/angular/material/samples/basic/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ import * as code from './code';
55

66
class MyResourceLoader extends ResourceLoader {
77
get(url: string): Promise<string> {
8+
let searchString = url.replace(/[\/\.-]/gi, '_');
9+
10+
// TODO(sancheez): fix load templates with relative url (relative url in Component)
11+
if (url.startsWith(".")) {
12+
searchString = searchString.substring(2);
13+
}
14+
815
const templateId = Object.keys(code).find((key) =>
9-
key.includes(url.replace(/[\/\.-]/gi, '_'))
16+
key.includes(searchString)
1017
);
1118
const template = code[templateId];
1219
if (!template) {

apps/codelab/src/app/codelabs/angular/router/samples/simple-router/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ import * as code from './code';
55

66
class MyResourceLoader extends ResourceLoader {
77
get(url: string): Promise<string> {
8+
9+
let searchString = url.replace(/[\/\.-]/gi, '_');
10+
11+
// TODO(sancheez): fix load templates with relative url (relative url in Component)
12+
if (url.startsWith(".")) {
13+
searchString = searchString.substring(2);
14+
}
15+
816
const templateId = Object.keys(code).find((key) =>
9-
key.includes(url.replace(/[\/\.-]/gi, '_'))
17+
key.includes(searchString)
1018
);
19+
1120
const template = code[templateId];
1221
if (!template) {
1322
console.log(template);

apps/codelab/src/app/components/angular-test-runner/angular-test-runner.component.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ export class SimpleAngularTestRunnerComponent
126126
url: '/assets/runner',
127127
},
128128
({ evalJs }) => {
129+
evalJs(this.scriptLoaderService.getScript('chai'));
129130
// evalJs(this.scriptLoaderService.getScript('shim'));
130-
// evalJs(this.scriptLoaderService.getScript('zone'));
131+
evalJs(this.scriptLoaderService.getScript('zone'));
131132
}
132133
);
133134

@@ -136,13 +137,8 @@ export class SimpleAngularTestRunnerComponent
136137
'<app-root></app-root><my-app></my-app><div class="error"></div>'
137138
);
138139

139-
sandbox.evalJs(this.scriptLoaderService.getScript('chai'));
140140
sandbox.evalJs(this.scriptLoaderService.getScript('mocha'));
141141
sandbox.evalJs(this.scriptLoaderService.getScript('test-bootstrap'));
142-
// sandbox.evalJs(this.scriptLoaderService.getScript('shim'));
143-
// sandbox.evalJs(this.scriptLoaderService.getScript('zone'));
144-
// sandbox.evalJs(this.scriptLoaderService.getScript('system-config'));
145-
// sandbox.evalJs(this.scriptLoaderService.getScript('ng-bundle'));
146142

147143
this.subscription = this.changedFilesSubject.subscribe((files) => {
148144
addMetaInformation(sandbox, this.code);
@@ -152,7 +148,8 @@ export class SimpleAngularTestRunnerComponent
152148
.filter(([path]) => path.match(/\.js$/) && !path.startsWith('code'))
153149
.map(([path, code]) => {
154150
try {
155-
sandbox.evalJs(`console.log('I remove modul')`);
151+
152+
sandbox.evalJs(`console.log('I remove module')`);
156153
sandbox.evalJs(code);
157154
} catch (e) {
158155
console.groupCollapsed(e.message);

apps/codelab/src/app/shared/angular-code/bootstrap.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ import { AppModule } from './app.module';
55

66
class MyResourceLoader extends ResourceLoader {
77
get(url: string): Promise<string> {
8+
9+
let searchString = url.replace(/[\/\.-]/gi, '_');
10+
11+
// TODO(sancheez): fix load templates with relative url (relative url in Component)
12+
if (url.startsWith(".")) {
13+
searchString = searchString.substring(2);
14+
}
15+
816
const templateId = Object.keys(code).find((key) =>
9-
key.includes(url.replace(/[\/\.-]/gi, '_'))
17+
key.includes(searchString)
1018
);
1119
const template = code[templateId];
1220
if (!template) {

0 commit comments

Comments
 (0)