Angular 在AlertController中找不到离子2实例方法

Angular 在AlertController中找不到离子2实例方法,angular,typescript,ionic2,Angular,Typescript,Ionic2,我正试图从ionic使用Alert Controller,但当将方法传递给handler选项时,我在实例上声明的handler方法内部使用的任何方法在单击select按钮时都显示为not found(未找到)。我有两个按钮,一个是取消,另一个是删除。当点击ddelete按钮时,我得到了错误信息。我有以下资料: 代码 import { Component, ViewChild, OnInit } from '@angular/core'; import { FormBuilder, Control

我正试图从ionic使用Alert Controller,但当将方法传递给handler选项时,我在实例上声明的handler方法内部使用的任何方法在单击select按钮时都显示为not found(未找到)。我有两个按钮,一个是取消,另一个是删除。当点击d
delete
按钮时,我得到了错误信息。我有以下资料:

代码

import { Component, ViewChild, OnInit } from '@angular/core';
import { FormBuilder, ControlGroup, Validators } from '@angular/common';
import { AlertController,LoadingController, NavController, ModalController, Slides, ViewController } from 'ionic-angular';

import { ShareUsageService } from './share.service';

@Component({
    selector:'brt-share',
    templateUrl: 'build/share/share.component.html'
})
export class ShareUsageComponent implements OnInit{
    //public properties
    emailForm: ControlGroup;
    submitAttempt: boolean = false;
    friends: string[] = [];

    constructor(
        public alertController: AlertController,
        public formBuilder: FormBuilder, 
        public shareService: ShareUsageService){
        this.createForm();
    }

    ngOnInit(){
        this.shareService.getFriends()
            .then(data => {this.friends = data;});

    }
    // public methods

    /**
     * @name deleteFriend
     * @description
     * Dismisses the modal to show the request view.
     */
    deleteFriend(){
        this.createForm();
        this.shareService.deleteFriend()
            .then(data => this.friends = data);
    }

    showDeleteConfirm(friendEmail:string) {
    let confirm = this.alertController.create({
      title: 'Delete this Friend?',
      message: 'Are you sure you to delete ' + friendEmail + '. This friend will no longer have access to your data.' ,
      buttons: [
        {
          text: 'Cancel',
          handler: () => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Delete',
          handler: this.deleteFriend 
        }
      ]
    });
    confirm.present();
  }

    createForm(){
        this.emailForm = this.formBuilder.group({
            email:['', Validators.compose([Validators.required])]
        });
    }

}
我收到一个错误,说明找不到
this.createForm

错误

zone.js:260 Uncaught EXCEPTION: Error in ./AlertCmp class AlertCmp - inline template:42:68
ORIGINAL EXCEPTION: TypeError: this.createForm is not a function
ORIGINAL STACKTRACE:
TypeError: this.createForm is not a function
    at Object.ShareUsageComponent.deleteFriend [as handler] (http://10.229.100.115:8100/build/js/app.bundle.js:890:14)
    at AlertCmp.btnClick (http://10.229.100.115:8100/build/js/app.bundle.js:51780:24)
    at DebugAppView._View_AlertCmp10._handle_click_0_0 (AlertCmp.template.js:1130:35)
    at http://10.229.100.115:8100/build/js/app.bundle.js:32781:24
    at http://10.229.100.115:8100/build/js/app.bundle.js:46228:36
    at http://10.229.100.115:8100/build/js/app.bundle.js:46314:111
    at ZoneDelegate.invoke (http://10.229.100.115:8100/build/js/zone.js:323:29)
    at Object.onInvoke (http://10.229.100.115:8100/build/js/app.bundle.js:38148:41)
    at ZoneDelegate.invoke (http://10.229.100.115:8100/build/js/zone.js:322:35)
    at Zone.runGuarded (http://10.229.100.115:8100/build/js/zone.js:230:48)
ERROR CONTEXT:
[object Object]

你能把你的代码放在那里吗?(您可以将
this.friends
数组设置为模拟数组)。这样我们就可以看一看,更容易看到发生了什么。你找到解决办法了吗?我也在为同样的问题苦苦挣扎。@TobiasW您使用的是哪个版本的Ionic?我发现了问题,但记不起答案是什么was@inspired看起来我在别的地方犯了个错误——我再也不会犯这个错误了。谢谢你的邀请!你能把你的代码放在那里吗?(您可以将
this.friends
数组设置为模拟数组)。这样我们就可以看一看,更容易看到发生了什么。你找到解决办法了吗?我也在为同样的问题苦苦挣扎。@TobiasW您使用的是哪个版本的Ionic?我发现了问题,但记不起答案是什么was@inspired看起来我在别的地方犯了个错误——我再也不会犯这个错误了。谢谢你的邀请!