I\'m trying to make use of the Angular Material table. I\'m trying to use the same code as the examples they have but I tin into a problem when I have to define the [d
even if you use static datas you will have to instantiate a new DataSource.
mat-table always need a real DataSource in @Input. DataSource is an abstract class, so you have to implement a class who inherit from DataSource.
This DataSource must have a method "connect" implemented which will return an Observable of the data you want to display.
So in your case something like that should work ;
// in your component
interface MyDataType {
ID: number;
Code: string;
}
export class StaticDataSource extends DataSource {
constructor(private staticData: MyDataType[]) {
super();
}
connect(): Observable {
return Observable.of(this.staticData);
}
disconnect() {}
}
...
this.staticDataSource = new StaticDataSource(data);
// in your template