how use NGXS with in mat-table DataSorce

2019-08-27 17:23发布

问题:

I use trying to use ngxs state managment pattern with angular material tables, but I don't know how to do it... Can anyone help?

  export class JobsComponent implements OnInit {
 public  dataSource = new JobsDataSource(this.jobsServise);
 //@Select(HomeState.jobs) public jobs$: Observable<boolean>
  displayedColumns = ['number', 'date', 'mawb', 'origin', 'destination', 'other'];
  constructor(
    private jobsServise: JobsService,
    private store: Store) {

   }
  ngOnInit() {
   // this.store.dispatch( new GetJobs());
  }
}

export class JobsDataSource extends DataSource <any> {
  public jobs: IJobs[];

  constructor(private jobsServise: JobsService){
    super();
  }
  public connect(): Observable<IJobs[]>{
   return this.jobsServise.getJobs();
  }
  public disconnect(){}
}