PeterStaev / NativeScript-Drop-Down

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

Property 'length' does not exist on type 'ValueList<string>' #233

Closed ArigarasuthanRepo closed 3 years ago

ArigarasuthanRepo commented 4 years ago

I am developing android and ios application using nativescript-angular. I have used the Drop-Down plugin for showing a list of security questions. When I was iterating the value list type array I have an error like "Property 'length' does not exist on type 'ValueList'".How to fix the issue?

PeterStaev commented 4 years ago

Hey @ArigarasuthanRepo , I'm not sure how you are iterating but you need to use simple for loop and not for...of.... The ValueList extends the built in NS ObservableArray so you iterate both the same way.

ArigarasuthanRepo commented 4 years ago

I am iterating the array like:

var securityQuestion:ValueList<string>=new ValueList<string>();

securityQuestion = this.renderData();

 for(var k=0; k<this.securityQuestion.length; k++)
{
}
PeterStaev commented 4 years ago

This should work, but no idea what renderData does in your code. If you are still having problems create a reproducible example in the NS playground so I can take a look at it.

ArigarasuthanRepo commented 4 years ago

Render data is a function to render values to securityQuestion array.

    renderData()
    {
        var renderSpinnerArray:ValueList<string>=new ValueList<string>();
        let valueItems=[]
        for(var k=0; k<this.commonArray.length; k++)
        {
            valueItems.push({
                value:this.commonArray[k].id,
                display:this.commonArray[k].question
            });
        }

        renderSpinnerArray = new ValueList<string>(valueItems);

         return renderSpinnerArray;
    }
ArigarasuthanRepo commented 4 years ago

how to add your plugin to nativescript playground?

ArigarasuthanRepo commented 4 years ago

Hai, I was created project regarding dropdown in native script playground and added the drop-down plugin to the playground project but it returns an error like="Cannot find module 'nativescript-drop-down/angular'".

Screenshot:

Screen Shot 2020-02-05 at 1 48 48 PM

PeterStaev commented 4 years ago

In the playground the NPM packages are added as folders to your project. So you need to import them with a relative path: ./nativescript-drop-down/angular for example

ArigarasuthanRepo commented 4 years ago

it was also returns an same error.

i was put the path like:

import { DropDownModule } from "~/app/nativescript-drop-down/angular";

ArigarasuthanRepo commented 4 years ago

Hello, are you there?. I did not get any response from you

PeterStaev commented 4 years ago

No idea why you are having problems. Here, it worked pretty straightforward. Here is the link: https://play.nativescript.org/?template=play-ng&id=EVOojq

ArigarasuthanRepo commented 4 years ago

place your drop-down module in home.module.ts file.it is returns an error.

PeterStaev commented 4 years ago

Its called RELATIVE path not w/o a reason 😉 You need to adjust it import { DropDownModule } from "../nativescript-drop-down/angular"

ArigarasuthanRepo commented 4 years ago

Ok thank you its worked.but returns an error while importing value list: import { ValueList } from "../nativescript-drop-down/angular"

PeterStaev commented 4 years ago

Sorry for the late response, just noticed that I did not answer your last question. You are importing the value list wrong, it should be: import { ValueList } from "../nativescript-drop-down"

PeterStaev commented 3 years ago

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