I have a material Data-table called in my component where the data is being called from an API which is defined in a service and called in the component which is working fine but when I apply the Data-table with Filtering which is provided at the material.io is not working as expected for whatever reason I don't know the filter part doesn't work?
Can anyone please help?
There are no errors or anything unusual I have tried various ways of shuffling the code and searching for this problem still nothing found.
Here is my code of component TS :
import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { ViewAgentInformationDetailComponent } from '../view-agent-information-detail/view-agent-information-detail.component'
import { MatTableDataSource, MatPaginator, MatDialog } from '@angular/material';
import { protractor } from 'protractor/built/ptor';
import { Router, ActivatedRoute } from '@angular/router';
import { Element } from '../userinfo';
import { InfoService } from '../info.service';
import { MatPaginatorModule } from '@angular/material/paginator';
@Component({
selector: 'app-view-agent-information',
templateUrl: './view-agent-information.component.html',
styleUrls: ['./view-agent-information.component.scss']
})
export class ViewAgentInformationComponent implements OnInit {
dataSource;
data: Element[];
constructor(private router: Router, public Info: InfoService) { }
displayedColumns = ['ViewOpt', 'CustID', 'PremiseID', 'Status', 'Market'];
ngOnInit() {
this.Info.getCustomers().subscribe(data => {
this.dataSource = data
console.log("Data Source: ");
console.log(this.dataSource);
})
}
applyFilter(filterValue: string) {
this.data = this.dataSource;
console.log(this.data);
filterValue = filterValue.trim();
filterValue = filterValue.toLowerCase();
this.dataSource.filter = filterValue;
}
onSelect(element) {
this.Info.changeData(element);
this.router.navigate(['/dashboard/viewinfo', element.cust_id])
}
}