angular-qrcode

QR Code elements for AngularJS.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
angular-qrcode
41807.2.06 years ago7 years agoMinified + gzip package size for angular-qrcode in KB

Readme

Angular QR Code
````html ````
An AngularJS directive to create QR Codes using Kazuhiko Arase’s qrcode-generator library.
See it in action.

Installation

````bash npm install angular-qrcode ````

Script elements

````html ````
````js angular .module('your-module', 'monospaced.qrcode', ); ````

ES2015

````js import qrcode from 'qrcode-generator'; import ngQrcode from 'angular-qrcode';
// hacks for the browser // if using webpack there is a better solution below window.qrcode = qrcode; require('/nodemodules/qrcode-generator/qrcodeUTF8');
angular .module('your-module', ngQrcode, ); ````

ES2015 + webpack

Add the following to webpack.config.js:
````js new webpack.ProvidePlugin({ qrcode: 'qrcode-generator', }) ````
Import everything, no need for window or require hacks:
````js import qrcode from 'qrcode-generator'; import qrcodeUTF8 from '/nodemodules/qrcode-generator/qrcodeUTF8'; import ngQrcode from 'angular-qrcode';
angular .module('your-module', ngQrcode,
); ````

Important!

Version and Error Correction

The amount of data a qrcode can contain is impacted by its version and error-correction-level.
version designates the density of the encoding. If it isn't specifed, it defaults to 5. If the version specified is too small to contain the data given, the next highest version will be tried automatically.
The maximum supported version is 40, and error-correction-leveldefaults to M.
For more information see http://www.qrcode.com/en/about/version.html.

Usage

as element
````html ````
with QR options
````html ````
as a downloadable image
````html ````
as a link to URL
````html ````
download and href can’t be used on the same element (if download is present, href will be ignored)
with expressions, observe changes
````html ````

Options

Permitted values
  • version: 1–40 (default: 5) - if required, will be auto-incremented to contain data given

  • error-correction-level: L, M, Q, H (default: M)

  • size: integer (default: size is calculated automatically)

  • download: boolean (default: false)

  • href: url as string

  • color: hex as string (default: #000)

  • background: hex as string (default: #fff)

The amount of data (measured in bits) must be within capacity according to the version and error correction level, see http://www.qrcode.com/en/about/version.html.

Demo

monospaced.github.io/angular-qrcode

Reference

QR Code versions
QR Code error correction