Reputation: 1660
I have this service which is used to get from rest point List of Objects:
@Injectable({
providedIn: 'root'
})
export class MerchantService {
constructor(private http: HttpClient) {
}
getMerchantsList(): Observable<Array<MerchantList>> {
return this.http.get<Array<MerchantList>>(environment.api.urls.merchants.getMerchants);
}
}
Object:
export class Merchant {
constructor(
public id: string,
public name: string,
public state_raw: string,
public users: string,
) {}
}
Component:
@Component({
selector: 'app-contract',
templateUrl: './contract.component.html',
styleUrls: ['./contract.component.scss']
})
export class ContractComponent implements OnInit {
merchants: MerchantList[];
constructor(private merchantService: MerchantService,
private route: ActivatedRoute) {
}
ngOnInit() {
this.merchantService.getMerchantsList()
.subscribe(value => {
if (value != null) {
this.merchants = value;
}
});
}
How I can print the content of the Array<MerchantList>>
into table?
I would like to print the Array content into each table row.
Upvotes: 0
Views: 50