PeterStaev / nativescript-image-swipe

A NativeScript widget to easily :point_up_2: and :mag: through a list of images
Apache License 2.0
35 stars 21 forks source link

Two-way sync is not working #22

Closed Jeetah closed 6 years ago

Jeetah commented 6 years ago

2-way sync like [(items)]="imgList" leads to this error:

ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '[object Object],[object Object]'. Current value: '[object Object]'.

Would be nice if this component would allow this - else it's very inconvenient to set the items dynamically.

PeterStaev commented 6 years ago

Hey @Jeetah , you dont really need 2-way binding for the items since the plugin does not edit the items at all.

Jeetah commented 6 years ago

Yes, I know. But I want to edit the items (add, delete) according to certain actions on the same page - and that's normally done via 2-way binding...

PeterStaev commented 6 years ago

Well actually no, you don't need 2-way binding. The plugin does not perform any kind of operations on the bound array. You only need 2-way binding only if the plugin has some functions that add/delete images.

In your case you have to add overlay buttons to add/delete. Then in your component you should handle the click of those buttons and perform the additions/removal to the bound array and the plugin will reflect the changes with the 1-way binding.

Jeetah commented 6 years ago

Yes I tried this. 2-way is not necessary. But the changes were not reflected - although I cleared the array and set new items. Only those from inInit stayed there. But will try again.

PeterStaev commented 6 years ago

No further response so closing this one for now. In case you still have problems, please provide more details.

san3k1990 commented 5 years ago

Hi. Thanks for your plugin, but i have same problem. I have a button. And when i click the button, then i change imgList. (I clean imgList and add new images). If count img in old imgList == count img in new imgList , then plugin show old images. If count in new imgList > count in old imgList -> i have exception: System.err: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 2, found: 3 Pager id: 13 Pager class: class com.tns.gen.android.support.v4.view.ViewPager_swipe_115_28_StateViewPager Problematic adapter: class com.tns.gen.android.support.v4.view.PagerAdapter_swipe_133_28_ImageSwipePageAdapter Version plugin 4.1.1