docs: update web-worker syntax (#42306)

With this change we update the worker initialization syntax to reflect that used in Angular CLI 12.

Closes #42302

PR Close #42306
This commit is contained in:
Alan Agius 2021-05-25 10:49:53 +02:00 committed by Zach Arend
parent 29e5d509aa
commit d15a6a3a71
1 changed files with 1 additions and 1 deletions

View File

@ -42,7 +42,7 @@ The command performs the following actions.
<code-example language="typescript" header="src/app/app.component.ts"> <code-example language="typescript" header="src/app/app.component.ts">
if (typeof Worker !== 'undefined') { if (typeof Worker !== 'undefined') {
// Create a new // Create a new
const worker = new Worker('./app.worker', { type: 'module' }); const worker = new Worker(new URL('./app.worker', import.meta.url));
worker.onmessage = ({ data }) => { worker.onmessage = ({ data }) => {
console.log(`page got message: ${data}`); console.log(`page got message: ${data}`);
}; };