ionic error : TypeError: _co.toggleRecoder is not a function

ionic error : TypeError: _co.toggleRecoder is not a function

我正在做一个离子项目,我遇到了错误

错误是

ERROR TypeError: _co.toggleRecoder is not a function

我将 TypeScript 代码放在下面 我已经为 function toggleRecoder()[=30= 编写了逻辑]

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  public items = ['apple' , 'orange'];
  public todos= [];
  public reordertoggle =  false;
  ladder: any;



  constructor(public navCtrl: NavController , public _AlertController : AlertController ) {

  }


 toggleReorder(){
        this.reordertoggle = !this.reordertoggle;
        console.log(this.reordertoggle);
    }


  openTodoAlert(){
    let addTodoAlert = this._AlertController.create({
        title:"Add A todo",
        message:"Enter your todo",
        inputs:[
        {
            type:"text",
            name:"addTodoInput"
        }],
        buttons:[
        {
            text:"Cancel"
          },

          {
              text: 'add',
              handler: (addInput) => {
                  let addInputField;
                  addInputField = addInput.addTodoInput;
                  this.todos.push(addInputField);
                  console.log(this.todos[0]);
                  console.log(this.reordertoggle); 
              }
          }
        ]
    });
      addTodoAlert.present();
      console.log(this.reordertoggle); 
  }




}

这是添加列表的模板

<ion-header>
      <ion-navbar>
        <ion-title>
         TODO
        </ion-title>
    <ion-buttons end>
     <button (click)='toggleReorder()' ion-button *ngIf="!reordertoggle">
     Edit 
    </button>
     <button (click)='toggleRecoder()' ion-button *ngIf="reordertoggle">
     Done
    </button>  
      <button ion-button (click)="openTodoAlert()">
          <ion-icon name="add"></ion-icon>
        </button>

    </ion-buttons>    
      </ion-navbar>

    </ion-header>

    <ion-content padding>

      <ion-list [reorder]='reordertoggle' (ionItemReorder)="reorderItems($event)">
        <ion-item-sliding  *ngFor="let todo of todos"> 
        <ion-item> {{todo}} </ion-item>
        <ion-item-options side='right'>
          <button color='danger' ion-button>
             <ion-icon name='trash'></ion-icon>
            </button>

</ion-item-options>
         </ion-item-sliding>
      </ion-list>
    </ion-content>

当我点击按钮 "add" 然后 toggleRecoder() 被调用,但我得到错误

离子错误:类型错误:_co.toggleRecoder 不是函数

这是一个打字错误。组件包含 'toggleReorder' 函数。您在模板中调用 'toggleRecoder'。

这行看起来像是一个简单的错字

 <button (click)='toggleRecoder()' ion-button *ngIf="reordertoggle">
     Done
 </button> 

但是在打字稿中,方法声明如下 -

toggleReorder(){
        this.reordertoggle = !this.reordertoggle;
        console.log(this.reordertoggle);
    }

在打字稿文件中,您将方法名称提到为 toggleReorder,但在这里您在按钮的 click 事件中使用了 toggleRecoder。因此它无法找到该方法。