Ad

Property Control Name Does Not Exist On Type Any[] When Pass ControlName To Another Array?

I have two array

first filter list array and represent by filterlist controlName

second filter bind and represent by filter bind filterName

my issue i face is cannot pass filter list control name to filter bind filterName

it show to me error property control name does not exist on type any[] ?

error display on line of

this.tempFilter=this.FilterBinddata.filter(x=>x.filterName==this.FilterList.controlName) ;

so how to solve this issue

FilterList:any[]=[];
FilterBinddata=any[]=[];
tempFilter=any[]=[];
 this._displayreport.GetReportFilteresById(param2).subscribe((data: any[]) => {
        this.FilterList = data;

      });

      this._displayreport.GetReportFilterBind(param2).subscribe((data2: any[]) => {
        this.FilterBinddata = data2;



   this.tempFilter=this.FilterBinddata.filter(x=>x.filterName==this.FilterList.controlName) ;

filter list data returned

datalistfilter [{"controlName":"ddlCompanyName","visableFlag":1},{"controlName":"ddlRegulation","visableFlag":1}]

filter bind data returned as

{"filterName":"ddlCompanyName","reportSource":"ZPower","reportSource2":"Text1"},{"filterName":"ddlCompanyName","reportSource":"ZYWYN Corporation","reportSource2":"Text1"},{"filterName":"ddlRegulation","reportSource":"ChinaROHS","reportSource2":"Text2"},{"filterName":"ddlRegulation","reportSource":"HalogenFree","reportSource2":"Text2"}
Ad

Answer

You can use any of this two quick Fix to overcome the error message

this.tempFilter=this.FilterBinddata.filter(x=>x.filterName==(this.FilterList as any).controlName);

OR

this.tempFilter=this.FilterBinddata.filter(x=>x.filterName==this.FilterList["controlName"]);
Ad
source: stackoverflow.com
Ad