FilterSelect form component not work with FormBuilder

plugins

#1

Hi I want use Nativescript form with formbuilder: https://angular.io/api/forms/FormBuilder
I I have textField or SegmentedBar in form it works ok.
But when I use this filter-select plugin: https://github.com/moayadnajd/nativescript-filter-select
It sends empty string, but i have selected item in filter select. How i can connect filter-select with formBuilder.
onSearch method print form value: {“agesC”:""} but i expected form value: {“agesC”:“1”}
My code now is:

<StackLayout class="form" height="100%" [formGroup]="clubsSearchForm">
      <FilterSelect
              [items]="ages"
              formControlName="agesC"
              modal_title="age" search_param="name"
              primary_key="id"
              multiple="false"
              allowSearch="false">
      </FilterSelect>


  <Button class="btn btn-primary btn-active" verticalAlignment="bottom" id="button" text="search" (tap)="onSearch($event)"></Button>

</StackLayout>

and appropriate class:


export class ClubsSearchFormComponent implements OnInit {
  clubsSearchForm: FormGroup;
  agesC: AbstractControl;
  ages: Array<Object> = [];



  constructor(private fb: FormBuilder, private clubsSrv: ClubsService, private asDataProviderSrv: ASDataProviderService, private routerExtensions: RouterExtensions) {
    this.clubsSearchForm = this.fb.group({
      "agesC": ["", [Validators.required]]
    });

    this.agesC = this.clubsSearchForm.controls['agesC'];
  }

  ngOnInit() {   
          this.ages = [ {"id": 1, "name": "6let"}]    
  }


  onSearch(args: EventData) {
    console.log(`form value: ${JSON.stringify(this.clubsSearchForm.value)}`);
  }
}


#2

The plugin doesn’t implement support for Angular Forms, it should implement a ControlValueAccessor in order to do that. You are welcome to write one.