Ionic Alert create error


#1

I have below simple code trying to create an Alert. But, it gave “Cannot read property ‘create’ of undefined” error when I tried to load it. I am using ionic 2.0 rc.

error_handler.js:47 EXCEPTION: Error in ./AccountDetailPage class AccountDetailPage - inline template:38:23 caused by: Cannot read property 'create' of undefined
import { Component } from '@angular/core';

import { PopoverController, AlertController, ViewController, NavParams } from 'ionic-angular';
import { AccountService } from '../../service/account-service';
import { ShopCategoryPopoverPage } from './vendor-category-popover';

@Component({
  selector: 'page-account-detail',
  templateUrl: 'account-detail.html',
})
export class AccountDetailPage {

  constructor (
    public popoverCtrl: PopoverController,
    public alertCtrl: AlertController,
    private viewCtrl: ViewController,
    private navParams: NavParams,
    public account_service: AccountService
  ) {
  }

  saveAccount() {
    this.account_service.saveAccount();
  }

  chooseShopCategory() {
    let alert = this.alterCtrl.create();
    alert.setTitle('Shop Category');

    alert.addInput({
      type: 'radio',
      label: 'Food',
      value: 'Food'
    });

    alert.addInput({
      type: 'radio',
      label: 'Professional',
      value: 'Professional'
    });

    alert.addButton('Cancel');
    alert.addButton({
      text: 'Ok',
      handler: data => {
        console.log("Shop category: ", data);
      }
    })

    alert.present();
  }

  ionViewWillEnter() {
    console.log("Loading account detail ...");
    this.account_service.loadAccount();
  }

  ionViewWillLeave() {
    //console.log("Leaving account detail page ...");
  }

  dismiss() {
    this.viewCtrl.dismiss();
  }
}
  "dependencies": {
    "@ionic/storage": "^1.0.3",
    "ionic-angular": "^2.0.0-rc.0",
    "ionic-native": "^2.0.3",
    "ionicons": "^3.0.0",
    "ng2-cordova-oauth": "0.0.6"
  },
  "devDependencies": {
    "@ionic/app-scripts": "latest",
    "typescript": "^2.0.3"
  },

#2

watch your typo error
alertCtrl
alterCtrl


#3

Thank you very much!