[英]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: 我刚刚从RC 4升级到Angular 2最终版本,现在遇到错误,我的代码上
cannot find name 'module'
:
@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
Edit after updated question: 更新问题后进行编辑:
Your HTML template is incorrect, you have a self-closing span element like this: 您的HTML模板不正确,您有一个如下所示的自闭合span元素:
<span class="icon-external-link" />
which is not allowed in HTML. HTML不允许使用。
Change it to <span class="icon-external-link"></span>
将其更改为
<span class="icon-external-link"></span>
Before edit: 编辑之前:
Are you using the latest angular-cli with Webpack? 您是否在Webpack上使用最新的angular-cli? If yes, you should remove all
moduleId
references, as this upgrade guide describes: 如果是,则应删除所有
moduleId
引用,如本升级指南所述:
https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14 https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14
- Remove all mention of moduleId: module.id.
删除所有提及的moduleId:module.id。 In webpack, module.id is a number but Angular expect a string.
在webpack中,module.id是一个数字,但是Angular需要一个字符串。
Try removing it then, should do it for all your components in your app 然后尝试将其删除,应对您应用中的所有组件进行删除
@Component({
selector: 'dashboard',
templateUrl: 'dashboard.component.html',
styleUrls: ['dashboard.component.css'],
styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']
})
app.module.ts app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { DashboardComponent } from './dashboard-component/dashboard-component.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
AppComponent,
DashboardComponent
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.