angular2-qrcode is a component that you can easily integrate into your project. It relies on qrcode-generator to generate QR Codes.
npm install angular2-qrcode
import { NgModule } from '@angular/core';
import { QRCodeModule } from 'angular2-qrcode';
...
@NgModule({
imports: [
QRCodeModule,
...
]
})
In component template:
<div>
<qr-code [data]="'All QR Code data goes here!'" [size]="150"></qr-code>
</div>
import {Component, OnInit} from '@angular/core';
import {QRCodeComponent} from 'angular2-qrcode';
@Component({
selector: 'my-qr-code-component',
directives: [QRCodeComponent],
template: `
<div>
<qr-code [data]="'All QR Code data goes here!'" [size]="150"></qr-code>
</div>
`
})
Attribute | Type | Default | Description |
---|---|---|---|
data | String | '' | Your data string |
size | Number | 128 | This is the height/width of your QR Code component |
level | String | 'M' | QR Correction level ('L', 'M', 'Q', 'H') |
type | Number | 4 | Buffer size for data string |
If you have code length overflow
errors, you need to increase the [type]
value to increase the buffer for your data string.
MIT License