Angular2 TypeScript – 错误TS2307:无法find模块'angular2 / forms'
我的组件文件包含:
import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `<user></user> `, }) export class AppComponent { }
我的app.modules:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angluar/forms'; import { AppComponent } from './app.component'; import { UserComponent } from './components/user.component'; @NgModule({ imports: [ BrowserModule ,FormsModule], declarations: [ AppComponent, UserComponent], bootstrap: [ AppComponent ] }) export class AppModule { }
当我尝试编译我的代码,我得到这个错误: 错误TS2307:找不到模块'angular2 /窗体'谢谢!
你有一个错字:
import { FormsModule } from '@angluar/forms';
应该:
import { FormsModule } from '@angular/forms';
你的代码有错误
在这里检查新的:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { UserComponent } from './components/user.component'; @NgModule({ imports: [ BrowserModule ,FormsModule], declarations: [ AppComponent, UserComponent], bootstrap: [ AppComponent ] }) export class AppModule { }