I have this piece of code:
import { Component } from '@angular/core';
import { NavController, Loading, Alert } from 'ionic-angular';
@Component({
templateUrl: 'build/pages/search/search.html',
})
export class SearchPage {
constructor (....)
{
// code here
}
findItems()
{
let loading = Loading.create({
content: "Finding items..."
});
this.nav.present(loading);
// other stuff here
}
When I run ionic serve
everything shows correctly but when I click a button which calls findItems()
method I get this error:
Error TS2341: Property 'create' is private and only accessible within class 'Loading
An analogous errors appears if I do:
let alert = Alert.create({
title: 'Hello!',
});
In this case in my terminal appears following message:Error TS2341: Property 'create' is private and only accessible within class 'Alert'.
I'm working with Ionic2 version 2.0.0-beta.36
EDIT: This only applies to beta 11 and higher
This is because
create
is a private function of the classLoading
, and therefore not callable outside of theLoading
class.The code example from Ionic's documentation shows a
LoadingController
class used to instantiate the Loading object with the desired options. I would start there.It looks like the syntax for Alerts has changed. Here's the new syntax: