I am encountering an issue where I can retrieve the list, but as soon as I input any of my data, I receive an error
ERROR TypeError: Cannot read properties of null (reading 'valueChanges')
. How can I resolve this? I have verified the name of my form array and it seems to be correct. Can anyone provide guidance or solutions?
filteredOptions:any;
options = [];
this.serviceLogForm = this.fb.group({
id:[0],
Name:[],
ArrayForm:this.fb.array([this.CreateArray()])
})
CreateArray(){
return this.fb.group({
item:['']
})
}
ngOninit{
this.ArrayForm.get('item').valueChanges.subscribe(response => {
console.log('data is ', response);
this.filterData(response);
})
}
filterData(enterData){
this.filteredOptions = this.options.filter(item => {
return item.toLowerCase().indexOf(enterData.toLowerCase()) > -1
})
}
getData(){
this.services.dataList(true).subscribe((response) => {
this.options = response;
this.filteredOptions = response;
console.log(response)
})
}
Here's my services where I map the items of my list and retrieve the specific data
dataList(isActive: Boolean){
let params = new HttpParams();
params = params.append('isActive', String(isActive));
return this.http.get(this.appsetting.baseURL + 'myList/list',{params})
.pipe(
map((response:any) => response.items.map(items =>items['Name']))
);
}