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

fix(stackblitz): fix dialogs not working #5899 #228 #8750 #356

Merged
merged 1 commit into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/app/shared/stackblitz/stackblitz-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,30 @@ export class StackblitzWriter {
fileContent = fileContent.replace(/{{version}}/g, VERSION.full);
} else if (fileName == 'main.ts') {
// Replace the component name in `main.ts`.
// For example, `import {MaterialDocsExample} from 'material-docs-example'`
// Replace `import {MaterialDocsExample} from 'material-docs-example'`
// will be replaced as `import {ButtonDemo} from './button-demo'`
fileContent = fileContent.replace(/MaterialDocsExample/g, data.componentName);
fileContent = fileContent.replace(/{MaterialDocsExample}/g, `{${data.componentName}}`);

// Replace `declarations: [MaterialDocsExample]`
// will be replaced as `declarations: [ButtonDemo]`
fileContent = fileContent.
replace(/declarations: \[MaterialDocsExample\]/g,
`declarations: [${data.componentName}]`);

// Replace `entryComponents: [MaterialDocsExample]`
// will be replaced as `entryComponents: [DialogContent]`
fileContent = fileContent.
replace(/entryComponents: \[MaterialDocsExample\]/g,
`entryComponents: [${data.componentName}]`);

// Replace `bootstrap: [MaterialDocsExample]`
// will be replaced as `bootstrap: [ButtonDemo]`
// This assumes the first component listed in the main component
const componentList = data.componentName.split(',')[0];
fileContent = fileContent.
replace(/bootstrap: \[MaterialDocsExample\]/g,
`bootstrap: [${componentList}]`);

fileContent = fileContent.replace(/material-docs-example/g, data.indexFilename);
}
return fileContent;
Expand Down
3 changes: 1 addition & 2 deletions src/assets/stackblitz/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import {CdkTableModule} from '@angular/cdk/table';
export class DemoMaterialModule {}

@NgModule({

imports: [
BrowserModule,
BrowserAnimationsModule,
Expand All @@ -90,7 +89,7 @@ export class DemoMaterialModule {}
MatNativeDateModule,
ReactiveFormsModule,
],

entryComponents: [MaterialDocsExample],
declarations: [MaterialDocsExample],
bootstrap: [MaterialDocsExample],
providers: []
Expand Down