ค้นหาเว็บไซต์

วิธีล้างช่องกรอกข้อมูลใน Ionic v3 โดยใช้ TypeScript


ดังนั้น ฉันมีช่องป้อนข้อมูล และฉันต้องการล้างข้อความในช่องเมื่อคลิกส่ง ฉันไม่แน่ใจว่าจะทำอย่างไรใน TypeScript สำหรับ Ionic

นี่คือโค้ดของฉัน:

 <ion-footer>
    <ion-item>
        <ion-input id="testId" type="text" placeholder="Type your Message here..." [(ngModel)]="newmessage"></ion-input>
        <button ion-button clear item-right (click)="send()">Send</button>
    </ion-item>
</ion-footer>

นี่คือไฟล์ Ts ของฉัน

 send(){

    this.ref.push({
        //key:this.ref.push().key("hello"),
        name: this.name,
        message: this.newmessage,
        phNo: this.data3,


    });

คำตอบ #1

สวัสดี นี่ช่วยได้ไหม?

send(){
    this.ref.push({
        //key:this.ref.push().key("hello"),
        name: this.name,
        message: this.newmessage,
        phNo: this.data3,
    });
    this.newmessage = ""; //clear this.newmessage
    }

คำตอบ #2

ตรวจอันนี้

 <ion-view title="Standard">
  <ion-content class="has-header" ng-controller="calcCtrl">
    <form id="calcForm" name="calcForm" ng-submit="submitData(calculate)">
      <label class="item-input">
        <span class="input-label">Price</span>
        <input class="input-label" type="text" placeholder="$0.00" ng-model="calculate.price">
      </label>

      <label class="item-input ">
        <span class="input-label">Discount</span>
        <input class="input-label" type="text" placeholder="$0.00" ng-model="calculate.discount">
      </label>
    </form>
  </ion-content>

  <ion-footer-bar class="bar-stable">
    <div class="buttons pull-right">
      <button class="button button-positive" ng-click="resetForm()">Clear</a>
    </div>
  </ion-footer-bar>
</ion-view>






  $scope.clearFields = function() {
$scope.calculate = angular.copy(calcForm);
$scope.calcForm.$setPristine();
}

ตรวจสอบสิ่งนี้