2

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

But in the html view:

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

this remains zero.

The method:

  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

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

Any suggestions?

Sas Gabriel
  • 1,544
  • 2
  • 20
  • 27

2 Answers2

2

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

This might resolve your problem!

Community
  • 1
  • 1
Manuel Taber
  • 427
  • 5
  • 19
  • thanks for the information, i will have a look at it as soon as possible and let you know if it works – Sas Gabriel Sep 22 '16 at 06:49
  • the main problem is the same like in other GUIs, if you want to update the GUI from another thread you can't, for angular this can be resolved with NgZone – Sas Gabriel Sep 24 '16 at 06:59
0

Your ondrag handler is attempting to use item which is actually a string - literally the iterated value of the items array. This means your code is throwing an exception on item.getSlidingPercent which doesn't exist. Try using event instead of item, like this:

  ondrag(event, item) {
    let percent = event.getSlidingPercent();
    if (percent === 1) {   
        event.close();
        this.Counter--;
    }
    if (percent + 1 === 0) {
        event.close();
        this.Counter++;
    }
  }
sherb
  • 5,845
  • 5
  • 35
  • 45
  • the problem remains even when using event, the Counter on html remains the same, also on plnkr the value in the class seems that it doesn't change. Thanks for trying, i think the only way to reproduce this is on a local machine – Sas Gabriel Sep 20 '16 at 07:43