E.Benedos
E.Benedos

Reputation: 1767

How to generated list of QR Codes?

I need to generate a QR code list after an HTTP GET call in Angular using angularx-qrcode (10.0.11). I'm not able to understand how to pass my customer code var to <qrcode/> element.

This is my simply implementation:

<h3>Customers QR</h3>
<li *ngFor="let customer of customers">
    <qrcode [qrdata]="{{customer.code}}" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
</li>
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { environment } from 'src/environments/environment';

@Component({
  selector: 'app-customers-qr',
  templateUrl: './customers-qr.component.html',
  styleUrls: ['./customers-qr.component.scss']
})
export class CustomersQrComponent implements OnInit {
  customers: any[];

  constructor(private http: HttpClient) { }

  ngOnInit(): void {
    this.http.get<any>(`${environment.baseUrl}/customers`).subscribe((customers) => {
      // Assign articles to table
      this.customers = customers;
    });
  }

}

It does not work. How can I implement my desired behaviour?

Upvotes: 0

Views: 517

Answers (1)

E.Benedos
E.Benedos

Reputation: 1767

Solution was very simply:

<qrcode [qrdata]="customer.code" [width]="128" [errorCorrectionLevel]="'M'"></qrcode>

Upvotes: 1

Related Questions