Home:ALL Converter>Angular Material Table with object as datasource

Angular Material Table with object as datasource

Ask Time:2019-03-25T18:46:29         Author:RidRoid

Json Formatter

My component looks like this :

import { Component, OnInit } from '@angular/core';
import { Member} from '../entities/Member'; 
import { SearchService } from './search.service';

@Component({   
  selector: 'app-search',   
  templateUrl: './search.component.html',   
  styleUrls: ['./search.component.scss']})

export class SearchComponent implements OnInit {

  members: Member[] = [];  
  constructor(private searchService: SearchService) { }

  ngOnInit() {
    this.searchService.getPartenaires().subscribe(
        member=> {
          this.members= member;
        }
    );   
  } 
}

I haven't figured out how to display my objects on a material table using ngFor. the examples on https://material.angular.io/components/table/overview are always using arrays as DataSource.

Should I put my objects into an array before passing them to the HTML? or is there a way to loop through them? thanks.

Author:RidRoid,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55336045/angular-material-table-with-object-as-datasource
yy