Hello,
as the title already reveals, I have some troubles with dataBinding in our app, since we are starting to upgrade to NativeScript 3.0.
We have one page on our app, where we dynamically create a TabView with a variable count of TabItems based on the JSON response of the server. Each TabItem contains a ListView with different data items.
While everything went perfect until using NS 2.5, the binding between an ObservableArray and the ListView (in the current tab of the TabView) does not work anymore and I don't know why.
While building the TabView, I iterate through the root-list, add one TabItem to the TabView and I create a new ObservableArray like this for each TabItem, that contains the sub-data and this should be visualized by a ListView. I define the ObservableArray like this:
vmModule.vmCategoriesRoot.set(
"categoriesSub"
+ index,
new
observableArrayModule.ObservableArray([]));
where vmCategoriesRoot is my Observable for the Page and index contains the selectedTabIndex of the TabView.
The code above works with NativeScript 2.5, but not with 3.0 and I don't know why. When trying to get the ObservableArray using vmModule.vmCategoriesRoot.get("categoriesSub" + index), it just says it is undefined. I noticed that I could use the following workaround:
vmModule.vmCategoriesRoot[
"categoriesSub"
+ index] =
new
observableArrayModule.ObservableArray([]);
This works, but I always used to access the components in my Observable via get and set and I do not know why I need to change the way of accessing a field in my Observable here to get this to work here.
I have created a sample project here, which should help you to reproduce this behaviour. You only need to switch between tns-core-modules 2.5.2 and 3.0 to see the difference.
Best regards and thank you in advance,
Marc