我有以下类组件: EmployeeComponent
我在其他类 ExampleDataSource
中用作超类,并从中继承了一个方法和属性它。最后,我还使用TableEmployees
运算符从 GenerateDataSource
创建 new
中的实例,以便传递{{ 1}}。
问题在于,在创建实例表单dataSoure
时,需要一个参数(这是有意义的)。我试图通过:TableEmployees
但是测试抛出以下错误:
的 this.dataSource
Property 'dataSource' does not exist on type 'EmployeeComponent'.
employee.component.ts
dataSource用于: export class EmployeeComponent implements OnInit {
constructor(public empService:EmployeesService, public http:Http) {}
ngOnInit() { this.getEmployees(); }
getEmployees() {
this.empService.getUsersList()
.subscribe(
(res) => {
this.userGetData = res.message;
},(err) => {
this.errorMessage = err;
}
)
}
}
export class TableEmployees {
displayedColumns = ['uid', 'email', 'name'];
dataSource = new GenerateDataSource(//HERE I'VE TO PASS THE PARAMETER );
}
export class GenerateDataSource extends DataSource<any> {
constructor(public usrComponent:UsersComponent){
super();
}
connect(): Observable<Element[]> {
alert(this.usrComponent.userGetData);
return Observable.of( this.usrComponent.userGetData );
}
disconnect() {}
}
:
employess.component.html