Arigarasuthan
Arigarasuthan

Reputation: 373

Property 'push' does not exist on type in ValueList Dropdown

Hai am developing android and ios application using native script-angular.I have used a nativescript-drop-down plugin in my app.I have used valuelist array to plot values in the dropdown. But the value list return error like "Property 'push' does not exist on type in ValueList Dropdown".I don't know how this issue arises. Help me to fix the issue.

My Sample code:

My Html:

<StackLayout orientation="vertical">
    <DropDown [items>="items"></DropDown>   
</StackLayout>

My Component ts file:

import { Component } from "@angular/core";
import {ValueList} from "nativescript-drop-down";


@Component({
    selector: "my-app",
    templateUrl:"app.component.html",
})

export class AppComponent {
    public items:ValueList<string>;

        constructor() {
        this.items = [];
         for(var k=0; k<10; k++)
        {
            items.push({
                value:k,
                display:"Hello World"
            })
        }

    }


}

Upvotes: 0

Views: 488

Answers (1)

Ganesh
Ganesh

Reputation: 6016

Try this..

you are doing assigning array which is not ValueList bype where as items variable is. So I guess that's what causing the issue.

Consider below code which is mentioned like in the Documentation.

   public items: ValueList<string>;

   constructor() {
      let valueItems = [];

      for(var k=0; k<10; k++) {
         valueItems.push({
             value:k,
             display:"Hello World"
         });
      }

     this.items = new ValueList<string>(valueItems);

}

I think you have a typo in Template code..

<StackLayout orientation="vertical">
    <DropDown [items]="items"></DropDown>   
</StackLayout>

Hope this helps.. :)

Upvotes: 1

Related Questions