Modal issues in Ionic 2


#1

Hello guys! I am just discovering ionic 2 and got to a little issue. I want to create a modal in ionic 2, but somehow the create in Modal.create(LoginsuccessPage); gets underlined. It says:

Property 'create' does not exist on type 'typeof Modal'.

Here is the full home.ts file:

import { Component } from '@angular/core';

import { NavController, Modal, NavParams } from 'ionic-angular';
import { LoginsuccessPage } from '../loginsuccess/loginsuccess'

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

  constructor(public navCtrl: NavController) {
    
  }


  login(){

    let modalPage = Modal.create(LoginsuccessPage);
    modalPage.present();


    this.navCtrl.push(LoginsuccessPage, {
      myString: "Simon"
    });
  }
}

Any idea what went wrong here?


#2

you need to instantiate the modalCtrl via dependency injection --> like NavController in your code.


#3

It worked! Thank you! :slight_smile: