PeterStaev / NativeScript-Drop-Down

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

cannot find name UILabel, cannot find namespace android #70

Closed magar91 closed 7 years ago

magar91 commented 7 years ago

Hello I made a simple example of a Nativescript Drop Down but I get the following error:

node_modules/nativescript-drop-down/drop-down.d.ts(40,14): error TS2304: Cannot find name 'UILabel'.

node_modules/nativescript-drop-down/drop-down.d.ts(41,18): error TS2503: Cannot find namespace 'android'.

this is my html file:


<ActionBar title="settings">
  <NavigationButton android.systemIcon="ic_menu_back" (tap)="goBack()"></NavigationButton>
</ActionBar>

<StackLayout>
    <Label text="test" textWrap="true"></Label>
    <DropDown #APIDropDown [items]="APIList" [selectedIndex]="APIIndex"
    (selectedIndexChanged)="ApiChanged($event)"></DropDown>
</StackLayout>

the error appeared after I added a import in the typescript file, this is the .ts file:

import {Component, OnInit, ViewChild, ElementRef} from '@angular/core';
import { RouterExtensions } from 'nativescript-angular/router';
//error appeared after adding SelectedIndexChangedEventData import
import { SelectedIndexChangedEventData } from "nativescript-drop-down";

import { ValueList, IValueItem } from '../../shared/value-list/value-list.model';

@Component({
  selector: 'settings',
  templateUrl: 'pages/settings/settings.component.html',
  styleUrls: ['pages/settings/settings-common.css', 'pages/settings/settings.css'],
})
export class SettingsComponent implements OnInit {

    public APIList : Array<string>;
    public APIIndex : number;

    ngOnInit(){
        this.APIList = new Array<string>();
        this.APIList.push("item1");
        this.APIList.push("item2");
        this.APIIndex = 0;

    }

    constructor(private nav : RouterExtensions) {}

    public goBack(){
        this.nav.backToPreviousPage();
    }

    public ApiChanged(args: SelectedIndexChangedEventData)
    {
        alert(args.oldIndex.toString());
        alert(args.newIndex.toString());
    }

}
PeterStaev commented 7 years ago

take a look at https://github.com/PeterStaev/NativeScript-Drop-Down/issues/39#issuecomment-252548468 this explains how to solve the issue.