我正在做 Angular2 Heroes 教程:https ://angular.io/docs/ts/latest/tutorial/toh-pt1.html 在纯 Javascript(不是 Typescript)中,我在导入表单模块时遇到了问题:(描述仅适用于打字稿):
在我们对表单输入使用双向数据绑定之前,我们需要在我们的 Angular 模块中导入 FormsModule 包。我们将它添加到 NgModule 装饰器的导入数组中。此数组包含我们的应用程序使用的外部模块列表。
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
FormsModule
],
declarations: [
AppComponent
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
当我将 Forms 模块添加到我的 app.module.js 导入数组时,它无法找到该模块:
zone.js:129 未捕获错误:模块“class2”导入的意外值“undefined”
这是我的 app.module.js:
(function(app) {
app.AppModule =
ng.core.NgModule({
imports: [ ng.platformBrowser.BrowserModule, ng.common.FORM_DIRECTIVES],
declarations: [ …Run Code Online (Sandbox Code Playgroud)