angular - 如何生成二维码列表?
问题描述
我需要在 Angular 中使用 HTTP GET 调用后生成一个二维码列表angularx-qrcode (10.0.11)
。我无法理解如何将我的客户代码 var 传递给<qrcode/>
元素。
这是我的简单实现:
<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;
});
}
}
这没用。我怎样才能实现我想要的行为?
解决方案
解决方案非常简单:
<qrcode [qrdata]="customer.code" [width]="128" [errorCorrectionLevel]="'M'"></qrcode>
推荐阅读
- android - React 本机相机无法渲染
- oracle - 在不等待结果的情况下运行 oracle sql 命令
- python - 如何将 pandas 数据帧的 hdf5 二进制文件保存在内存中?
- reactjs - React - 从 17.0.1 更新到 17.0.2 时出错
- typescript - 在手写的 d.ts 文件中,如何从模块根目录中的一个命名空间公开函数?
- opencv - darknet_images.py 没有检测到任何物体。暗网 YOLOv4
- wordpress-rest-api - phpcUrl 不返回最新的 JSON 数据
- visual-studio-code - 远程 VS Code 上的 jupyter notebook 的颜色主题很奇怪
- excel - 在 Excel 中使用 VLOOKUP 不断返回 N/A 错误
- python - 有没有办法循环遍历熊猫数据框名称来绘制图形?