如何使用材料在 Angular 8 中显示带有 observabele 的过滤项目?

我有一个 Angular 8 应用程序和一个搜索表单。所以我可以像这样过滤来自服务的数据:


this.participantService.filterParticipantsByRegistration(1, "Invited", moment(this.startDate).format('YYYY MM D')).subscribe(result => {

    console.log(this.startDate.toString());

    console.log(result);


});

我看到正确的数据是这样的:


7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]

0: {participantId: "1df0b475-d463-47ba-29a4-08d6ce7e67a4", email: "gjbh9@idmatica.nl", fullName: "Gert-Jan Boesschen Hospers", firstName: "Gert-Jan", lastNamePrefix: "", …}

1: {participantId: "6f5d3210-5650-41bd-bfb0-08d6d23579f3", email: "gjbh11@idmatica.nl", fullName: "Gert-Jan Boesschen Hospers", firstName: "Gert-Jan", lastNamePrefix: "", …}

2: {participantId: "e6fb0137-d21e-419b-bfb1-08d6d23579f3", email: "gjbh12@idmatica.nl", fullName: "Gert-Jan Boesschen Hospers", firstName: "Gert-Jan", lastNamePrefix: "", …}

3: {participantId: "ba645f8c-3b53-44d4-bfb2-08d6d23579f3", email: "gjbh15@idmatica.nl", fullName: "Gert-Jan Bosch

但是我的问题是,如何在材质网格中显示console.log?


蓝山帝景
浏览 165回答 1
1回答

红糖糍粑

您分配.subscribe方法的返回值,即订阅,但您需要结果,所以只需在.subscribe 中执行searchFor(part: ParticipantInfoDTO) {    this.participantService      .filterParticipantsByRegistration(1, "Invited", moment(this.startDate).format("YYYY MM D"))      .subscribe(result => {        this.datasource.filter = result;      });  }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript