Ionic 2 Popup


I have the error below when I try to show an alert popup after click on a button:

EXCEPTION: TypeError: Cannot read property ‘length’ of undefined in [null]
ORIGINAL EXCEPTION: TypeError: Cannot read property ‘length’ of undefined

This is my code:


<ion-content padding class="getting-started">

   <button primary (click)="showAlertPopup()">Alert</button>



import {Page, NavController, Popup} from 'ionic/ionic';

  templateUrl: 'app/popups/popups.html'

export class PopupsPage {
  constructor(nav: NavController, popup: Popup) {
       this.nav = nav;
       this.popup = popup;
           title: 'Ionic Popup',
           template: 'This is alert popup',

Thanks in advantage

Did you put:


in your root components template (app.js)?

Not sure if it really matters but does removing that comma at the end of:

template: 'This is alert popup',

make any difference?

I have that tag in app.html:

<ion-menu [content]="content">
            <button ion-item *ng-for="#p of pages" (click)="openPage(p)">

<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>


Is it not the right place?

As you said, no difference :smile:

Same here. Anybody have a working example?

It´s a bug, you need to update to the latest version of Ionic2 (alpha 37).

1 Like

Thank you, it works fine now

1 Like

title: ‘Ionic Popup’,
template: ‘This is alert popup’

is this working in beta version?