Angular错误:"Can't bind to 'ngModel' since it isn't a known property of 'input'"
大家好!我是Angular和TypeScript的新手,在尝试使用ngModel进行双向数据绑定时遇到了问题。我正在编写一个简单的笔记应用,这是我的代码:
```typescript
// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
noteTitle: string = '';
}
```
```html
```
运行应用(Angular 15)时,浏览器控制台出现错误:
"Can't bind to 'ngModel' since it isn't a known property of 'input'."
我检查了FormsModule已导入到AppModule中。这是我的app.module.ts:
```typescript
// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserMod
我的笔记
您输入了:{{ noteTitle }}