无法加载Angularjs 2 RC5表格

时间:2016-08-21 18:01:59

标签: angularjs angular angular2-template angular2-forms

这对表单来说非常烦人。 我的package.json是:

 "dependencies": {

     "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",

     "angular2-in-memory-web-api": "0.0.15",

    "systemjs": "0.19.36",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.11",
    "zone.js": "^0.6.12",

    "bootstrap": "^3.3.6"
  },

但是当我使用它时:

import { FormsModule }      from '@angular/forms';
@NgModule({
  imports: [ BrowserModule, FormsModule ],

发送错误,无法找到表单。此外,我不再在angular / forms目录中看到FormsModule。

有人可以帮我们告诉我你是如何在angular2中导入表格的吗?

我试过这个:

import { FORM_DIRECTIVES }      from '@angular/forms';
@NgModule({
  imports: [ BrowserModule, FORM_DIRECTIVES ],

但现在在我的webConsole中,我确实看到了:

zone.js:101 GET http://localhost:3010/node_modules/@angular/forms@0.3.0//bundles/forms.umd.js 404 (Not Found)

为什么它一直在向表单名称添加0.3.0?它应该是:

http://localhost:3010/node_modules/@angular/forms/bundles/forms.umd.js 

1 个答案:

答案 0 :(得分:0)

//在app.module.ts

//对于数据形式 - >

import { DataDrivenComponent } from "./data-driven/data-driven.component";
import { ReactiveFormsModule } from '@angular/forms';

//其他必要的导入

import { BrowserModule  } from '@angular/platform-browser';
import { AppComponent }   from './app.component';
import { NgModule } from '@angular/core';

// Ng模块

@NgModule({
    declarations: [AppComponent, DataDrivenComponent],
    imports: [BrowserModule, ReactiveFormsModule],
    bootstrap: [AppComponent]
})

//导出类

export class AppModule {}