Skip to content

Commit

Permalink
Fix multiple instance issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRClark committed May 28, 2021
1 parent 39106bf commit f1a0ca3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class AppModule {

ngDoBootstrap(){
const fbComp = createCustomElement(FileBrowseComponent, { injector: this.injector });
customElements.define('file-browse', fbComp);
if (!customElements.get('file-browse')) {
customElements.define('file-browse', fbComp);
}
}

}
7 changes: 5 additions & 2 deletions src/app/file-browse/file-browse.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export class FileBrowseComponent implements OnInit {
constructor(injector: Injector, private fileService: FileServiceService) {
// Convert `FileBrowseComponent` to a custom element.
const FileBrowseElement = createCustomElement(FileBrowseComponent, {injector});
// Register the custom element with the browser.
customElements.define('local-file-browse', FileBrowseElement);

if (!customElements.get('file-browse')) {
// Register the custom element with the browser.
customElements.define('file-browse', FileBrowseElement);
}
}

ngOnInit(): void {
Expand Down

0 comments on commit f1a0ca3

Please sign in to comment.