Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Type Error while presenting alert generated in external service?

$
0
0

@imatefx wrote:

I have an external class AlertHelper which contains predefined Alerts for Error and Success events.
when an event occurs i call the service function which returns an alert object and i present it using the nav in the related page.

@Injectable()
export class AlertHelper {
    showLoadingFailedAlert(): Alert {

        let alert = Alert.create({
            title: '_title',
            subTitle: '_subTitle',
            buttons: [{
                text: 'Ok',
                handler: () => {
                    console.log('Ok clicked');
                }
            }]
        });
        return alert;
    }
}

i call it like

this.nav.present(this.alertHelper.showLoadingFailedAlert());

My problem is
Typescript shows the following error:

Argument of type 'Alert' is not assignable to parameter of type 'ViewController'.

Some places it shows

Argument of type 'Alert' is not assignable to parameter of type 'ViewController'.
  Types have separate declarations of a private property '_cntDir'.

It works fine if i create an Alert locally.

Also Is there any possible way for me to pass the nav to the service so that the service can present the alert?

Posts: 8

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>