首页 > 解决方案 > 为什么需要添加文本更改事件以及我们如何在 Aurelia 应用程序中添加

问题描述

这样我们可以添加文本更改事件吗?分享一些有用的链接,我可以在其中学习 Aurelia 应用程序

文本框.ts

export class Textbox {

  @bindable textValue='';
  @bindable displayName: string;

  constructor(controllerFactory) {
    this.controller = controllerFactory.createForCurrentScope();
    this.controller.validateTrigger = validateTrigger.changeOrBlur;
    this.controller.addRenderer(new BootstrapFormRenderer());    
  }

  attached() : void {
    this.controller.validate(); 
  }
}

ValidationRules
.ensure((c:Textbox) => c.textValue)
.required().withMessage("This field is required!")
.maxLength(50)
.on(Textbox);

文本框.html

   <input type="text" placeholder.bind="placeholder" onchange="alert('textvalue changed')"  class="form-control" value.bind="textValue & validate">

应用程序.html

<template>
<textbox></textbox>
</template>

标签: typescriptaurelia

解决方案


推荐阅读