ionic 2没有更新html中的Counter属性 [英] ionic 2 not updating the Counter property in html

查看:101
本文介绍了ionic 2没有更新html中的Counter属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的例子,它确实更新了我的HomePage类中的Counter值。

I have this simple example which does update the Counter value in my HomePage class.

但是在html视图中:

But in the html view:

 <p>{{Counter}}</p>

这仍为零。

方法:

  ondrag(event, item) {
    let percent = event.getSlidingPercent();
    if (percent === 1) {            
        event.close();
        this.Counter--;
    }
    if (percent + 1 === 0) {
        event.close();
        this.Counter++;
    }
}

在我的机器上工作,如果我为每个添加日志

works on my machine if i add logs for each if

以下是plnkr上的代码:
https ://plnkr.co/edit/7Q4wDtZjIS1zBDsF0etS

Here is the code on plnkr: https://plnkr.co/edit/7Q4wDtZjIS1zBDsF0etS

有任何建议吗?

推荐答案

此主题已在另一个SO主题中讨论过: https://stackoverflow.com/a/35106069/2256927

This topic was already discussed in another SO thread: https://stackoverflow.com/a/35106069/2256927

这可能会解决您的问题!

This might resolve your problem!

这篇关于ionic 2没有更新html中的Counter属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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