How to generate QR Codes with Angular 10 ?
Last Updated :
19 Jul, 2021
QR Code (Quick Response Code) has become the essential component for each and every product, organization, app, etc. In marketing campaigns, we can use the generated QR code to
- Download apps
- Send Email
- View business location etc.
In this article let us see how to generate QR Codes with Angular 10.
Prerequisites: In your local development machine Node 10+, together with NPM 6+ must have been installed.
node --version
npm --version
Step 1: Installing Angular CLI 10
From the command line prompt, provide the following command to install
npm install -g @angular/cli
As per the current version, it will be installed, and best that the version should be 10+

Step 2: Let us create a new Angular app
We can use Visual Studio Code editor or even from the command line prompt, we can create a sample project that generates QR code
ng new <projectname>
Here let us have “angular10qrcodegeneration” as the projectname

Necessary packages will be installed
Now the project structure of “angular10qrcodegeneration” will be

Navigate to the project directory where package.json is present

Important file specifying the dependencies of the project
Step 3: To generate QRCode, we need the required dependency. It can be installed by using
npm install @techiediaries/ngx-qrcode
Once this is installed, in src->app->qrcodeapp.module.ts file, we can use
import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode';
And in
@NgModule({
imports: [ NgxQRCodeModule ] Can be given
We need to additionally import FormsModule. So, our src->app->app.module.ts snippet
qrcodeapp.module.ts
import { BrowserModule } from '@angular/platform-browser' ;
import { NgModule } from '@angular/core' ;
import { FormsModule } from '@angular/forms' ;
import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode' ;
import { QRCodeAppRoutingModule } from './qrcodeapp-routing.module' ;
import { QRCodeAppComponent } from './qrcodeapp.component' ;
@NgModule({
declarations: [
QRCodeAppComponent
],
imports: [
BrowserModule,
QRCodeAppRoutingModule,
NgxQRCodeModule,
FormsModule
],
providers: [],
bootstrap: [QRCodeAppComponent]
})
export class QRCodeAppModule { }
|
Now the library has been imported, and we can use the “ngx-qrcode” component in Angular application.
qrcodeapp.component.ts
import { Component } from '@angular/core' ;
import { NgxQrcodeElementTypes, NgxQrcodeErrorCorrectionLevels }
from '@techiediaries/ngx-qrcode' ;
@Component({
selector: 'app-root' ,
templateUrl: './qrcodeapp.component.html' ,
styleUrls: [ './qrcodeapp.component.css' ]
})
export class AppComponent {
title = 'angular10qrcodegeneration' ;
elementType = NgxQrcodeElementTypes.URL;
correctionLevel = NgxQrcodeErrorCorrectionLevels.HIGH;
}
|
qrcodeapp.component.html
< ngx-qrcode
[elementType]="elementType"
[errorCorrectionLevel]="correctionLevel"
[value]="value"
cssClass = "qrcodeshadow" ></ ngx-qrcode >
< textarea [(ngModel)] = "value"></ textarea >
|
style.css
.qrcodeshadow {
display: flex;
align-items: center;
justify-content: center;
filter: drop-shadow(15px 15px 15px #e42424);
opacity: .5;
}
textarea {
margin-top: 15px;
display: block;
margin-left: auto;
margin-right: auto;
width: 400px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: large;
font-weight: bold;
color: green;
opacity: .5;
}
|
Steps to build the project
ng build (at the location where your package.json present)
Steps to run the project:
ng serve (at the location where your package.json present)
As the code is set run on port 4200, on hitting http://localhost:4200/, we can able to see the output as

We can specify any valid website URL, and we can generate QR codes successfully in Angular 10. In CSS, we can beautify the shadow display.
Let us see the output for the google website

Conclusion: Many important libraries like QRCode generators are available in npm Angular. We can effectively use them according to our needs. QRCode is an essential component for any application/mobile app etc.
Similar Reads
Generate QR code using AngularJS
In this article, we will see how to generate and display QR codes in our Angular apps. A QR code is a matrix of black and white squares that can be read by a camera or a smartphone. A QR code can store information and URLs that make it easy to read for a bot or smartphone user. In a business scenari
3 min read
How to Scan QR Codes with Google?
One can scan QR codes with Google in a pretty hassle-free manner and it's also rather convenient-simply put, use Google Lens, which is pre-installed on most Android devices and within the Google app. Direct scanning of QR codes through your camera is supported with no need for an extra app. In order
4 min read
Build a QR Code Generator Web App
A quick response code or QR code is a type of barcode in the form of a matrix. These are machine-readable optical labels that contain pieces of information about the items attached to them. In this article, we will be creating our own QR code generator from scratch using HTML, CSS, and JavaScript. W
5 min read
How to create a new component in Angular?
A component in Angular is the building block for making web pages. It is a reusable block of code that can be used anywhere in the app any number of times. It provides scalability, reusability, and readability. Each component does a specific job like showing a menu, a photo or a card, etc. In this a
3 min read
How to Create a new module in Angular ?
Modules are most important when it comes to building strong and scalable Angular applications. They help organize your code, promote modularity, and improve maintainability. It encourages collaboration among developers by grouping related components, directives, pipes, and services. In this article,
3 min read
How to encode/decode URL using AngularJS ?
In this article, we will see the mechanism to encode/decode URL using AngularJS, along with knowing the different methods available to accomplish the given task, & will understand it through the illustration. A URL specifies a resource and its access protocol. Encode URL: URL Encoding is a way t
3 min read
How to make a QR Code generator using qrcode.js ?
Modern web applications require generating QR codes for certain features where we need to enable a convenient way of data sharing like QR codes for the end users. Some popular QR codes use cases are UPI payment addresses, invoice details, contact cards, web links, etc. QR(Quick Response) code is a m
6 min read
Generate an angular@16 project within nx workspace
Nx Workspace is a powerful tool that provides monorepo-style development for Angular projects. It offers enhanced capabilities for managing multiple applications, libraries, and shared code within a single workspace. In this article we will see how to generate an Angular 16 project withing NX worksp
2 min read
Quote Generator App Using Angular
A Quote Generator App is a simple application that displays random quotes to users. It is a great project for practising Angular basics such as components, services, data and API integration. Here we develop a simple Quote Generator App using Angular. This application can able to display a new Quote
6 min read
Generate a QR code in Node.js
Generating QR Code in Node can be helpful in sharing the url, images, text, and other data. A QR code is a monochromatic matrix with embedded data that is used in manufacturing industries in order to label products. Nowadays QR codes are being used for payments in UPI-based apps, some chatting apps
3 min read