PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Nativescript dropdown error #161

Closed HunterJS-bit closed 6 years ago

HunterJS-bit commented 6 years ago

Hello guys, Im using ns-dropdown plugin to display list of users, and Im getting that list async...And first time when I go to page everything works fine but after navigating back and forth my app crashes.

and Im getting this error

Binding error while setting property items of DropDown(165)@file:///app/views/test/test.xml:37:25;: TypeError: undefined is not an object (evaluating 'this._array[index].display')
JS ERROR TypeError: undefined is not an object (evaluating 'this._array[index].display')

When I get my list of users from server my code is:

var dropdown = require("nativescript-drop-down");
// users are object with data about user (name, username, age)
 var mappedUsers = userList.map(function(e){
                        return {
                            value: e,
                            display: e.name
                        }
                    });

viewModel.contactsList = new dropdown.ValueList(mappedUsers);

But when I switch my code to regular array like this: viewModel.contactsList = ['test', 'test2']; Everything works fine, but that is not a solution because I need whole object, but only name of user displayed... I have also tried with observableArray but still not working ???

PeterStaev commented 6 years ago

Hey @markomiljkovic , it looks like the users are not loaded or the index is incorrect. Make sure you are loading everything at the right time.

PeterStaev commented 6 years ago

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