
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
angularx-qrcode
Advanced tools
Simple QRCode module generator for Angular 4-20 and Ionic 3-8 using node-qrcode
angularx-qrcode - a fast and easy-to-use Ivy compatible Ionic and Angular QR Code Generator library
angularx-qrcode is compatible with Ionic 3-8 and Angular 4-20 with support for the Ivy compiler. It is a drop-in replacement for the no-longer-maintained angular component ng2-qrcode and based on node-qrcode.
Angular 20 and Ionic with angularx-qrcode 20
npm install angularx-qrcode --save
# Or with yarn
yarn add angularx-qrcode
Angular 19 and Ionic with angularx-qrcode 19
npm install angularx-qrcode@19.0.0 --save
# Or with yarn
yarn add angularx-qrcode@19.0.0
Angular 18 and Ionic with angularx-qrcode 18
npm install angularx-qrcode@18.0.2 --save
# Or with yarn
yarn add angularx-qrcode@18.0.2
Angular 17 and Ionic with angularx-qrcode 17
npm install angularx-qrcode@17.0.1 --save
# Or with yarn
yarn add angularx-qrcode@17.0.1
All supported angular versions
| Angular Version | angularx-qrcode Version |
|---|---|
| ^20 | ^20.0.0 |
| ^19 | ^19.0.0 |
| ^18 | ^18.0.2 |
| ^17 | ^17.0.1 |
| ^16 | ^16.0.2 |
| ^15 | ^15.0.1 |
| ^14 | ^14.0.0 |
| ^13 | ^13.0.15 |
| ^12 | ^12.0.3 |
| ^11 | ^11.0.0 |
| ^10 | ^10.0.12 |
| ^9 | ^2.3.7 |
| ^8 | ^2.1.4 |
| ^5 / ^6 / ^7 | ^1.6.4 |
| ^4 | ^1.0.3 |
Working online demo of Angular QR Code Generator
The source for the working angular app is available in projects/demo-app.
Run the command:
npm start
and open the url http://localhost:4200/ in your browser
The source for a live angularx-qrcode demo app and more examples how to implement angularx-qrcode is located in the directory projects/demo-app of this repository.
Since Angular 19, the latest version of the angularx-qrcode module is now exported as a standalone component. If you’re upgrading from a version before Angular 19, please replace the import statement with the component’s name since it’s now a standalone component.
# OLD - angular 18 and older
# File: app.module.ts
import { QRCodeModule } from 'angularx-qrcode';
# NEW - angular 19 and newer
// File: app.component.ts
import { QRCodeComponent } from 'angularx-qrcode';
For more uses with angular 18 and earlier see: angularx/qrcode as ngModule
// For angular 19, see above for angular 18 and older
// File: app.component.ts
// other imports...
import { QRCodeComponent } from 'angularx-qrcode';
@Component({
selector: "app-root",
imports: [
// other component imports...
QRCodeComponent,
],
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
// your code
}
// File: app.component.html
// all your HTML...
<qrcode [qrdata]="'Your data string'" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
Now that angular/Ionic know about the new QR Code component, let's invoke it from our template. If we use a simple text-string, we need no additional code in our controller.
<qrcode [qrdata]="'Your data string'" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
In addition to our <qrcode>-directive in app.component.html,
lets add two lines of code to our controller app.component.ts.
// File: app.component.ts
export class QRCodeComponent {
public myAngularxQrCode: string = null;
constructor () {
// assign a value
this.myAngularxQrCode = 'Your QR code data string';
}
}
// File: app.component.html
<qrcode [qrdata]="myAngularxQrCode" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
The online demo contains a working sample how to download the QR Code with a button.
To download the QR Code, we have to use the qrCodeURL attribute
of the <qrcode> which returns a sanitized URL representing the
location of the QR Code.
// File: example.ts
export class QRCodeComponent {
public myAngularxQrCode: string = "";
public qrCodeDownloadLink: SafeUrl = "";
constructor () {
this.myAngularxQrCode = 'Your QR code data string';
}
onChangeURL(url: SafeUrl) {
this.qrCodeDownloadLink = url;
}
}
// File: example.html
<qrcode (qrCodeURL)="onChangeURL($event)" [qrdata]="myAngularxQrCode" [width]="256" [errorCorrectionLevel]="'M'"></qrcode>
<a [href]="qrCodeDownloadLink" download="qrcode">Download</a>
The file format obtained by qrCodeURL depends directly on the
elementType of <qrcode>. If it's either canvas, url or image,
it returns an image as .png, if it's svg, returns a .svg file.
| Attribute | Type | Default | Description |
|---|---|---|---|
| allowEmptyString | Boolean | false | Allow qrdata to be an empty string |
| alt | String | null | HTML alt attribute (supported by img, url) |
| ariaLabel | String | null | HTML aria-label attribute (supported by canvas, img, url) |
| colorDark | String | '#000000ff' | RGBA color, color of dark module (foreground) |
| colorLight | String | '#ffffffff' | RGBA color, color of light module (background) |
| cssClass | String | 'qrcode' | CSS Class |
| elementType | String | 'canvas' | 'canvas', 'svg', 'img', 'url' (alias for 'img') |
| errorCorrectionLevel | String | 'M' | QR Correction level ('L', 'M', 'Q', 'H') |
| imageSrc | String | null | Link to your image |
| imageHeight | Number | null | height of your image |
| imageWidth | Number | null | width of your image |
| margin | Number | 4 | Define how much wide the quiet zone should be. |
| qrCodeURL | EventEmitter<SafeUrl> | Returns the QR Code URL | |
| qrdata | String | '' | String to encode |
| scale | Number | 4 | Scale factor. A value of 1 means 1px per modules (black dots). |
| title | String | null | HTML title attribute (supported by canvas, img, url) |
| version | Number | (auto) | 1-40 |
| width | Number | 10 | Height/Width (any value) |
Depending on the amount of data of the qrdata to encode, a minimum width is required.
angularx-qrcode supports AOT Compilation (Ahead-of-Time Compilation) which results in significant faster rendering. An AOT-enabled module is included. Further reading: https://angular.io/guide/aot-compiler
As of version 1.6.0, SSR support is fully implemented, the following workaround is no longer needed. HowTo use Angular QRCode with SSR
Support the development of angularx-qrcode (or even see your logo here?), consider sponsoring angularx-qrcode. Your support is much appreciated!
MIT License
Copyright (c) 2018 - present Andreas Jacob (Cordobo.com)
The 'qrcode' package is a popular library for generating QR codes in JavaScript. It is not specific to Angular and can be used in any JavaScript environment. It offers a wide range of customization options and supports various output formats such as canvas, SVG, and image files. Compared to angularx-qrcode, it requires more manual setup when used in Angular applications.
The 'ngx-qrcode2' package is another Angular library for generating QR codes. It is similar to angularx-qrcode in terms of functionality and ease of use. Both libraries offer similar customization options, but ngx-qrcode2 may have different API conventions and additional features.
FAQs
Simple QRCode module generator for Angular 4-21 and Ionic 3-8 using node-qrcode
The npm package angularx-qrcode receives a total of 280,287 weekly downloads. As such, angularx-qrcode popularity was classified as popular.
We found that angularx-qrcode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.