Ionic2:'NavController'类型中不存在属性'present' [英] Ionic2: Property 'present' does not exist on type 'NavController'

查看:842
本文介绍了Ionic2:'NavController'类型中不存在属性'present'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ionic 2 rc4 。我正在按照这里的建议进行操作执行以下操作:

I am using Ionic 2 rc4. I am following the advise here and am trying to do the following:

import { NavController } from 'ionic-angular';
        ...
    this.nav.present(this.loading).then(() => {

然而,对我来说,看起来 NavController 没有现在的函数,因为我得到:

However, to me it looks like the NavController does not have a present function, because I get:


[ts] Property 'present' does not exist on type 'NavController'.
any


我是否正确,或者我是我做错了什么?他们如何获得这个幽灵功能?

Am I correct, or am I doing something wrong? How do they get to access this "phantom" function?

任何建议都赞赏。

更新

这是我的代码导致以下错误(在 this.loading.present()上。然后(()=> {):

Here is my code that results in the following error (on this.loading.present().then(() => {):


无法读取属性 nativeElement'为null

它首次显示加载。但是在 submit(),则会显示> alert ,它会出现此错误。

It presents loading the first time. but after the alert is presented if submit() is run again, it gets this error.

submit() {
            this.loading.present().then(() => {
                let alert = this.alertCtrl.create({
                    title: 'Verify Email',
                    subTitle: 'Please verify your email address before you log in.',
                    message: 'Check your Spam folder if you cannot find the email.',
                    buttons: [
                        {
                            text: 'Resend',
                            handler: data => {
                                firebaseUser.sendEmailVerification().then((data) => {
                                    this.doAlert('Verify Email', 'Verification Email Sent.').then((data) => {
                                        //navCtrl.setRoot(navCtrl.getActive());
                                    });
                                });
                            }
                        },
                        {
                            text: 'Okay',
                            handler: data => {
                                //navCtrl.setRoot(navCtrl.getActive());
                            }
                        }
                    ]
                });
                alert.present();
                this.loading.dismiss();
            });
}


推荐答案

看着这个 Beta 11 的https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#breaking-changes-3 =nofollow noreferrer>更改日志

Looking at this changelog for Beta 11

他们从 Navcontroller 中删除​​了现在的函数。

They have removed present function from Navcontroller.

您需要重构代码并根据您的要求使用其他功能。
this.loading.present()

You need to refactor your code and use some other function based on your requirement. this.loading.present()

对于错误,请检查加载控制器文档。

For the error, check the Loading controller docs.


请注意,在组件被解除后,它将不再可用于
,并且必须创建另一个组件。这可以通过
来避免在可重复使用的
函数中包装组件的创建和呈现

Note that after the component is dismissed, it will not be usable anymore and another one must be created. This can be avoided by wrapping the creation and presentation of the component in a reusable function

this.loading = this.loadingCtrl.create({
   //loading properties
          });

之前在<$ c之前$ c> this.loading.present()

这篇关于Ionic2:'NavController'类型中不存在属性'present'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆