Skip to content

Commit 11db2b4

Browse files
committed
fixed load bundles
1 parent 4d55921 commit 11db2b4

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
@@ -125,8 +125,9 @@ export class SimpleAngularTestRunnerComponent
125125
url: '/assets/runner',
126126
},
127127
({ evalJs }) => {
128+
evalJs(this.scriptLoaderService.getScript('chai'));
128129
// evalJs(this.scriptLoaderService.getScript('shim'));
129-
// evalJs(this.scriptLoaderService.getScript('zone'));
130+
evalJs(this.scriptLoaderService.getScript('zone'));
130131
}
131132
);
132133

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

138-
sandbox.evalJs(this.scriptLoaderService.getScript('chai'));
139139
sandbox.evalJs(this.scriptLoaderService.getScript('mocha'));
140140
sandbox.evalJs(this.scriptLoaderService.getScript('test-bootstrap'));
141-
// sandbox.evalJs(this.scriptLoaderService.getScript('shim'));
142-
// sandbox.evalJs(this.scriptLoaderService.getScript('zone'));
143-
// sandbox.evalJs(this.scriptLoaderService.getScript('system-config'));
144-
// sandbox.evalJs(this.scriptLoaderService.getScript('ng-bundle'));
145141

146142
this.subscription = this.changedFilesSubject.subscribe((files) => {
147143
addMetaInformation(sandbox, this.code);
@@ -151,7 +147,8 @@ export class SimpleAngularTestRunnerComponent
151147
.filter(([path]) => path.match(/\.js$/) && !path.startsWith('code'))
152148
.map(([path, code]) => {
153149
try {
154-
sandbox.evalJs(`console.log('I remove modul')`);
150+
151+
sandbox.evalJs(`console.log('I remove module')`);
155152
sandbox.evalJs(code);
156153
} catch (e) {
157154
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)