我最近在Nativescript游乐场上开发了一个简单的应用程序,在那里我发现ngModel不能处理输入类型的TextField . 我已经确保我在应用程序的模块中导入NativescriptFormModule . 但它仍然无法正常工作 .
您使用扩展语法而不是ngModel( text 和 textChange ),因为TextFuield是具有多个可绑定属性(提示,文本,返回类型等)的复杂布局 - 示例Playground here和文档文章here
text
textChange
HTML
<TextField [hint]="hint" [text]="name" (textChange)="onTextChange($event)"></TextField>
打字稿
export class SignupComponent implements OnInit { name: string; hint: string = "enter name"; tf: TextField; onTextChange(args: EventData) { console.log("onTextChange"); this.tf = <TextField>args.object; console.log("tf.text: ", this.tf.text); } }
1 回答
您使用扩展语法而不是ngModel(
text
和textChange
),因为TextFuield是具有多个可绑定属性(提示,文本,返回类型等)的复杂布局 - 示例Playground here和文档文章hereHTML
打字稿