要解决Angular 2中输入文本框值没有更新的问题,但在花括号内使用时会更新的问题,可以按照以下步骤进行:
export class MyComponent {
name: string = '';
}
{{ name }}
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
FormsModule
],
// ...
})
export class AppModule { }
通过遵循以上步骤,应该能够解决输入文本框值没有更新的问题,并确保在花括号内使用时也能正确更新。