blubberbo blubberbo - 1 month ago 171
AngularJS Question

Angular 2 Final Release cannot find name module - moduleId: module.id

I just upgraded to the Angular 2 Final Release from RC 4 and I am now getting an error

cannot find name 'module'
on my code:

@Component({
selector: 'dashboard',
moduleId: module.id,
templateUrl: 'dashboard.component.html',
styleUrls: ['dashboard.component.css'],
styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']

})


Any ideas?

Thanks in advance!

UPDATE, this is the error:

zone.js:355 Unhandled Promise rejection: Template parse errors:
Only void and foreign elements can be self closed "span" ("i role="presentation"><a role="menuitem" tabindex="-1" href="http://BruinAlert.ucla.edu">BruinAlert [ERROR ->]<span class="icon-external-link" /></a></li>
<li role="presentat"): WidgetBankComponent@104:138
Only void and foreign elements can be self closed "span" ("tion"><a role="menuitem" tabindex="-1" href="https://logon.ucla.edu/passchange.php">Change Password [ERROR ->]<span class="icon-external-link" /></a></li>
at DirectiveNormalizer.normalizeLoadedTemplate (http://localhost:56159/node_modules/@angular/compiler//bundles/compiler.umd.js:13373:21)
at eval (http://localhost:56159/node_modules/@angular/compiler//bundles/compiler.umd.js:13366:53)
at ZoneDelegate.invoke (http://localhost:56159/node_modules/zone.js/dist/zone.js:203:28)
at Zone.run (http://localhost:56159/node_modules/zone.js/dist/zone.js:96:43)
at http://localhost:56159/node_modules/zone.js/dist/zone.js:462:57
at ZoneDelegate.invokeTask (http://localhost:56159/node_modules/zone.js/dist/zone.js:236:37)
at Zone.runTask (http://localhost:56159/node_modules/zone.js/dist/zone.js:136:47)
at drainMicroTaskQueue (http://localhost:56159/node_modules/zone.js/dist/zone.js:368:35)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:56159/node_modules/zone.js/dist/zone.js:308:25)consoleError @ zone.js:355_loop_1 @ zone.js:382drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308
zone.js:357 Error: Uncaught (in promise): Error: Template parse errors:(…)consoleError @ zone.js:357_loop_1 @ zone.js:382drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308

Answer

Edit after updated question:

Your HTML template is incorrect, you have a self-closing span element like this:

<span class="icon-external-link" />

which is not allowed in HTML.

Change it to <span class="icon-external-link"></span>


Before edit:

Are you using the latest angular-cli with Webpack? If yes, you should remove all moduleId references, as this upgrade guide describes:

https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14

  1. Remove all mention of moduleId: module.id. In webpack, module.id is a number but Angular expect a string.
Comments