Angular 无法使用角度5中的材质组件显示单个视图
我正在处理一个使用Angular 5、Material Component和firebase的项目,用于数据库目的。我在整个表的材料网格中有一个数据,即客户端。我正在单击视图中的图标,该图标必须显示子组件中的单个客户机数据,但物料表需要与数据源绑定,但我无法将单个客户机日期绑定到数据源。 单击查看功能后,它将导航到client-detail.component client.component.html client-detail.component.tsAngular 无法使用角度5中的材质组件显示单个视图,angular,angular5,angular2-routing,angular2-forms,angular2-services,Angular,Angular5,Angular2 Routing,Angular2 Forms,Angular2 Services,我正在处理一个使用Angular 5、Material Component和firebase的项目,用于数据库目的。我在整个表的材料网格中有一个数据,即客户端。我正在单击视图中的图标,该图标必须显示子组件中的单个客户机数据,但物料表需要与数据源绑定,但我无法将单个客户机日期绑定到数据源。 单击查看功能后,它将导航到client-detail.component client.component.html client-detail.component.ts displayedColumns=['
displayedColumns=['no','name','cemail','address','country','projects','proposallist','quotationlist'];
dataSource=新MatTableDataSource();
dataProject=新MatTableDataSource();
projects:AngularFirestoreCollection=this.pro.collection('project');
数组;
dataproject=this.projects.valueChanges();
applyFilter(filterValue:string){
filterValue=filterValue.trim();
filterValue=filterValue.toLowerCase();
this.dataSource.filter=filterValue;
}
@ViewChild(MatSort)排序:MatSort;
@ViewChild(MatPaginator)分页器:MatPaginator;
ngAfterViewInit(){
this.dataSource.paginator=this.paginator;
this.dataSource.sort=this.sort;
this.clientservice.getClient().subscribe(数据=>{
this.dataSource.data=数据;
})
}
您可以在两个组件之间使用sharedservice来显示其他组件中单击行的详细信息component@yer我已经这样做了,但是当我调用clientservice.getClient()方法时,它显示错误,因为getClient()方法接受参数,但在datatable中它不能接受任何参数。这是主要问题。
<ng-container matColumnDef="action">
<mat-header-cell *matHeaderCellDef>
<b>Action</b>
</mat-header-cell>
<mat-cell *matCellDef="let item">
<i class="material-icons" style="cursor: pointer;" (click)="onView(item)">visibility</i>
</mat-cell>
</ng-container>
onView(prod){
this.router.navigate(['./',prod.prodid,'view'],{relativeTo: this.route});
}
displayedColumns = ['no', 'name', 'cemail', 'address', 'country', 'projects', 'proposallist', 'quotationlist'];
dataSource = new MatTableDataSource<Client>();
dataProject = new MatTableDataSource<Project>();
projects: AngularFirestoreCollection<any> = this.pro.collection('project');
projectsarray: Array<any>;
dataproject = this.projects.valueChanges();
applyFilter(filterValue: string) {
filterValue = filterValue.trim();
filterValue = filterValue.toLowerCase();
this.dataSource.filter = filterValue;
}
@ViewChild(MatSort) sort: MatSort;
@ViewChild(MatPaginator) paginator: MatPaginator;
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.clientservice.getClient().subscribe(data => {
this.dataSource.data = data;
})
}