Can't create a modal


#1

SOLVED: The modal class was missing “export” (ie export class)

I’m having a problem when trying to load and present a modal in ionic 2. (i’ve shortened this code down a tad)

import {Page, NavController, Tabs, Storage, LocalStorage, Modal, Alert, NavParams} from 'ionic-angular';
import {TandCs} from '../termsandconditions'

@Page({
  templateUrl: 'build/pages/home/home.html'
})
export class Home {
    static get parameters() {
     return [[NavController],[Tabs],[Language]];
    }

    constructor(nav, tabs, language) {

      this.nav = nav;

    }

    onPageDidEnter() {
        console.log("here")
        var tandcs = Modal.create(TandCs);
        that.nav.present(tandcs);
    }

and my modal page…
import {ViewController, Page} from ‘ionic-angular’;
import {Language} from ‘…/langservice’;

@Page({
  template: `
<ion-toolbar>
  <ion-title>
    Description
  </ion-title>
  <ion-buttons start>
    <button (click)="dismiss()">
      <span primary showWhen="ios">Cancel</span>
      <ion-icon name="md-close" showWhen="android,windows"></ion-icon>
    </button>
  </ion-buttons>
</ion-toolbar>

<ion-content class="has-header">
  <ion-list>
      <ion-item>
        <h2>esrdfghio</h2>
        <p>afghjk</p>
      </ion-item>
  </ion-list>
</ion-content>`
})
class TandCs {

    static get parameters() {
        return [[ViewController], [Language]];
    }
    constructor(viewCtrl, language) {
        this.viewCtrl = viewCtrl;
        this.lang = language;
        this.language = { terms:  language.getTerm("Title, Terms and conditions 1") }
    }

    close() {
        this.viewCtrl.dismiss();
    }
}

But this returns the following exception…

 EXCEPTION: TypeError: Cannot read property 'annotations' of undefined

Any help will be greatly appreciated! Thank you!


#2

that should be this?


#3

Hmm, I’m not seeing an error in my tests.


#4

Sorry that ‘that’ was left over from a setTimeout wrapper


#5

@Colin Which version of the Ionic framework are you using? Is the exception thrown when showing the modal or when closing it? I had a similar problem before but it was fixed in beta.3.


#6

Hey, it’s b.4 but I have solved this issue - the modal class must be exported