gpt4 book ai didi

angular - @angular/forms/FormsModule 缺失

转载 作者:行者123 更新时间:2023-12-04 03:19:50 26 4
gpt4 key购买 nike

我正在尝试从 Angular 2 RC5 中的 @angular/forms@0.3.0 导入 FormsModule。应该很简单吧?

import { FormsModule } from '@angular/forms';

但是,这不是我使用安装的@angular/forms 库的一部分
npm install @angular/forms

有些人建议使用:
import { ReactiveFormsModule }   from '@angular/forms';

然而这也不起作用。

我查看了表单包,它似乎在 form_providers 输入文件 (form_providers.d.ts) 中,并且确实提到了 FormsModule。在 forms.js 中,它提到了 __export(require('./form_providers'));所以这意味着它应该可用吗?

任何想法我如何解决这个问题?

非常感谢

JT

app.module.ts
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {MeteorModule} from 'angular2-meteor';
import {AppComponent} from './app.component';


@NgModule({
imports: [BrowserModule, MeteorModule, FormsModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }

platformBrowserDynamic().bootstrapModule(AppModule,[ disableDeprecatedForms(),provideForms()]));

Package.json (“npm install”正在使用它)
{
"name": "angular2-meteor-base",
"private": true,
"scripts": {
"start": "meteor run",
"test": "meteor test --driver-package practicalmeteor:mocha",
"test:ci": "meteor test --once --driver-package dispatch:mocha-phantomjs"
},
"devDependencies": {
"chai": "3.5.0",
"chai-spies": "0.7.1"
},
"dependencies": {
"@angular/common": "^2.0.0-rc.5",
"@angular/compiler": "^2.0.0-rc.5",
"@angular/core": "^2.0.0-rc.5",
"@angular/forms": "latest",
"@angular/platform-browser": "^2.0.0-rc.5",
"@angular/platform-browser-dynamic": "^2.0.0-rc.5",
"@angular/router": "^3.0.0-rc.1",
"angular2-meteor": "latest",
"angular2-meteor-auto-bootstrap": "latest",
"angular2-meteor-polyfills": "latest",
"angular2-meteor-tests-polyfills": "latest",
"es6-shim": "0.35.1",
"lodash": "^4.15.0",
"meteor-node-stubs": "0.2.3",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12"
}
}

app.component.ts
import {Component} from '@angular/core';


@Component({
selector: 'app',
template: 'Hello World'
})

export class AppComponent {

constructor() {
}
}

最佳答案

我遇到了类似的问题,不得不更新我的 package.json 以将表单版本指定为以下内容:

"@angular/forms": "^0.3.0",

之后运行 npm 更新。

关于angular - @angular/forms/FormsModule 缺失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39167977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com