Closed sujanmah062 closed 7 years ago
hi, I'm building a component in nativescript, and I'm getting the following error "No value accessor for form control name:"modeDropdown".
mode.component.html <DropDown #modeDropdown name="modeDropdown" [items]="modes" [(ngModel)]="selectedMode" hint="Select Mode" row="0" col="1" style="background-color: lightgray; line-height: 20px; padding:5px 5px;border-radius: 4px;"></DropDown>
<DropDown #modeDropdown name="modeDropdown" [items]="modes" [(ngModel)]="selectedMode" hint="Select Mode" row="0" col="1" style="background-color: lightgray; line-height: 20px; padding:5px 5px;border-radius: 4px;"></DropDown>
mode.component.ts
import { Component, ElementRef, ViewChild } from '@angular/core'; import { SelectedIndexChangedEventData, ValueList, DropDown } from "nativescript-drop-down"; export class ModeComponent { @ViewChild("modeDropdown") modeDropdown: ElementRef; selectedMode=0; modes: ValueList<string> = new ValueList<string>(); constructor(){ this.getModes(); } getModes() { this. modes.push({ value: `1`, display: `Bonus`, }); this. modes.push({ value: `2`, display: `Exam`, }); let modeDropdown = (<DropDown>this.modeDropdown.nativeElement) modeDropdown.selectedIndex = this.modes.getIndex("1"); } }
i have importimport { NativeScriptFormsModule } from "nativescript-angular/forms"; in module.ts too.
import { NativeScriptFormsModule } from "nativescript-angular/forms";
@sujanmah062 , you need to import the drop down module in order to be able to use it in angular forms. Take a look at the demo-ng project as well as the readme which contains enough details on how to set it up.
hi, I'm building a component in nativescript, and I'm getting the following error "No value accessor for form control name:"modeDropdown".
mode.component.html
<DropDown #modeDropdown name="modeDropdown" [items]="modes" [(ngModel)]="selectedMode" hint="Select Mode" row="0" col="1" style="background-color: lightgray; line-height: 20px; padding:5px 5px;border-radius: 4px;"></DropDown>
mode.component.ts
i have import
import { NativeScriptFormsModule } from "nativescript-angular/forms";
in module.ts too.