Generate QR Code in Angular 10 (Easy)

Learn how to generate QR codes from a string using a third-party library easily, within 2 Minutes.2 min


QR code for Angular Integration.
TL;DR – Learn how to generate QR codes in Angular with our easy step-by-step guide. Quick, simple, and efficient.

In this article, we will use the third-party plugin named “NPM/angularx-QRcode” to create QR codes for your Angular and ionic applications. This plugin will work for Angular 2+ versions. To generate a QR code, follow the below steps. Within 2 minutes, you can convert your input string data to the QR code.

1. Install library to your project.

npm install angularx-qrcode — save

2. Update your “app.module.ts” file,

import { QRCodeModule } from 'angularx-qrcode';
...
@NgModule({
imports: [BrowserModule, FormsModule, QRCodeModule],
declarations: [AppComponent, HelloComponent],
bootstrap: [AppComponent]
})
...

3. Add code to your “main-app.component.ts” file,

import { Component} from '@angular/core';

@Component({
selector: 'my-main-app',
templateUrl: './main-app.component.html',
styleUrls: ['./main-app.component.css']
})
export class AppComponent {
public qrCodeStr: string = null;

constructor() {
this.qrCodeStr = 'Some string to generate QR Code';
}
}

4. Add code to your “main-app.component.ts” file,

<qrcode [qrdata]="'qrCodeStr'" [width]="300" [errorCorrectionLevel]="'M'"></qrcode>

Bingo, you did it.


References:

[1]. NPM library — angularx-qrcode

You may also like,

adsense


Discover more from 9Mood

Subscribe to get the latest posts sent to your email.


Like it? Share with your friends!

What's Your Reaction?

Lol Lol
0
Lol
WTF WTF
0
WTF
Cute Cute
0
Cute
Love Love
0
Love
Vomit Vomit
0
Vomit
Cry Cry
0
Cry
Wow Wow
0
Wow
Fail Fail
0
Fail
Angry Angry
0
Angry
Rakshit Shah

Legend

Hey Moodies, Kem chho ? - Majama? (Yeah, You guessed Right! I am from Gujarat, India) 25, Computer Engineer, Foodie, Gamer, Coder and may be a Traveller . > If I can’t, who else will? < You can reach out me by “Rakshitshah94” on 9MOodQuoraMediumGithubInstagramsnapchattwitter, Even you can also google it to see me. I am everywhere, But I am not God. Feel free to text me.

0 Comments

Leave a Reply

Choose A Format
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Meme
Upload your own images to make custom memes
Poll
Voting to make decisions or determine opinions
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Personality quiz
Series of questions that intends to reveal something about the personality
is avocado good for breakfast? Sustainability Tips for Living Green Daily Photos Taken At Right Moment