In this article, you will learn the following things.
- How to Create a QR Code?
- ng-qrcode
Nowadays everyone knows about QR codes. We are using QR codes in various places.
- For Payment: Gpay, PhonePe, IndianPost Pay App
- For Information: Hotel Menu on QR Code, Get any info on the scan.
- For Social App: Scan for Facebook and Instagram.
QR Code full form is a Quick Response (QR) code. In this session, we will learn how to create a QR code in angular.
How QR Code Implemented?
- Create Angular project - AnguDemo.
- Run the application and check project was created successfully.
- Install NPM package called ng-qrcode by command
Command
- First, implement UI/Frontend side coding.
- Understand the UI
We want to create a form on form there is following form controls.
- msg – TextBox (Input – Type Text) html control.
- qr-code Component of nx-qrcode library.
How QR Code get generated?
In the QR-code component pass data(values) to the value attribute. In this walkthrough, we are passing the msg variable. As you type/store the values in the msg variable your QR Code will get generated.
Step-by-step Implementation
Create an Angular project called “AnguDemo”.
command
Create a Component Called the qrcode
command
Open the app.component.html file.
Open app.component.ts file.
We are going to use the ng-code package.
command
![Install ng-qrcode]()
Open the qrcode.component.html file.
Open the qrcode.component.ts file.
OUTPUT
![Output]()
Go to the following link to check your QR Code:
https://scanqr.org/
![QR Code]()
![Scanned Data]()
QR Code generated and tested successfully.
Happy Coding.