Installation - Angular 5+, Ionic

NPM

npm install angularx-qrcode --save

Yarn

yarn add angularx-qrcode

Installation - Angular 4

NPM

npm install angularx-qrcode@1.0.2 --save

Yarn

yarn add angularx-qrcode@1.0.2

Basic Usage

Import the module and add it to your imports section in your main AppModule (file: app.module.ts)

// all your imports
import { QRCodeModule } from 'angularx-qrcode'; @NgModule({
declarations: [
AppComponent
],
imports: [
QRCodeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

Examples

Generate a QR Code from a string (directive only)

Now that Angular/Ionic knows about our QR Code module, we can invoke it from our template with a directive. If we use a simple text-string, we need no additional code in our controller.

<qrcode [qrdata]="'Your QR code data string'" [size]="256" [level]="'M'"></qrcode>

Create a QR Code from a variable in your controller

In addition to our <qrcode>-directive in example.html, we add two lines of code to our controller example.ts.

// example.ts:
export class QRCodeComponent {
public angularxQrCode: string = '';
// assign a value anywhere in/below your constructor
this.myAngularxQrCode = 'Your QR code data string';
} // example.html:
<qrcode [qrdata]="myAngularxQrCode" [size]="256" [level]="'M'"></qrcode>

Parameters

Attribute Type Default Description
allowEmptyString Boolean false Allow empty string
colorlight String '#ffffff' Dark color
colordark String '#000000' Light Color
level String 'M' QR Correction level ('L', 'M', 'Q', 'H')
qrdata String '' String to encode
size Number 256 Height / Width (any value)
usesvg Boolean false SVG Output

Note

Depending on the size (amoutn of data) of the qrdata to encode, a minimum size might be required.

git地址:https://github.com/Cordobo/angularx-qrcode

Angular生成二维码的更多相关文章

  1. 六、angular 生成二维码

    首先需要安装angular-qrcode : bower install monospaced/angular-qrcode npm install angular-qrcode 如何使用? 在相应的 ...

  2. JavaScript的学习--生成二维码

    有一些耗cpu的计算,完全可以在客户端上计算,比如生成二维码. qrcode其实是通过计算,然后使用jquery实现图形渲染和画图.支持canvas和table两种方式生成我们所需的二维码. 具体用法 ...

  3. Javascript生成二维码(QR)

    网络上已经有非常多的二维码编码和解码工具和代码,很多都是服务器端的,也就是说需要一台服务器才能提供二维码的生成.本着对服务器性能的考虑,这种小事情都让服务器去做,感觉对不住服务器,尤其是对于大流量的网 ...

  4. 使用jquery.qrcode生成二维码(转)

    jQuery 的 qrcode 插件就可以在浏览器端生成二维码图片. 这个插件的使用非常简单: 1.首先在页面中加入jquery库文件和qrcode插件. <script type=" ...

  5. iOS 生成二维码

    首先先下载生成二维码的支持文件 libqrencode 添加依赖库 CoreGraphics.framework. QuartzCore.framework.AVFoundation.framewor ...

  6. QR code 扩展生成二维码

    include './phpqrcode/phpqrcode.php';  //引入QR库 QRcode::png("leo", 'qrcode.png', 'L', 10);  ...

  7. Python 创建本地服务器环境生成二维码

    一. 需求 公司要做一个H5手机端适配页面,因技术问题所以H5是外包的,每次前端给我们源码,我们把源码传到服务器让其他人访问看是否存在bug,这个不是很麻烦吗?有人说,可以让前端在他们的服务器上先托管 ...

  8. C#通过第三方组件生成二维码(QR Code)和条形码(Bar Code)

    用C#如何生成二维码,我们可以通过现有的第三方dll直接来实现,下面列出几种不同的生成方法: 1):通过QrCodeNet(Gma.QrCodeNet.Encoding.dll)来实现 1.1):首先 ...

  9. 使用Spire.Barcode程序库生成二维码

    使用Spire.Barcode程序库生成二维码 某天浏览网页发现了一个二维码的程序库.它的描述说他可以扫描二维码图像.我很感兴趣,想试试他是不是会有用.所以我就用了些方法扫描二维码图像来测试一下.结果 ...

随机推荐

  1. UCML JS函数说明

    UCML JS函数说明1.调用父窗体函数 window.openerWindow.函数名 2.公用JS存放位置 BPObject\Model\Rule\initvalue.js 3.弹窗JS var ...

  2. VsCode源码分析之布局

    关于VsCode源码编译运行,请参考这篇文章:VsCode源码编译运行 当然了,也可以参考官方文档(所以这里就不再赘述):https://github.com/Microsoft/vscode/wik ...

  3. 深入浅出的webpack构建工具---devTool中SourceMap模式详解(四)

    阅读目录 一:什么是SourceMap? 二:理解webpack中的SourceMap的eval,inline,sourceMap,cheap,module 三:开发环境和线上环境如何选择source ...

  4. WebSockets通信

    WebSockets通信 1. websocket是什么?WebSocket是一种网络通信协议.2. 为什么需要websocket?我们有http协议,为什么还需要websocket协议呢?因为htt ...

  5. ESP8266开发综合篇(LUA开发-视频教程总揽)

    为了解决基础教程简单入门但不实用,项目方案非常实用但比较难的问题,开始推出8266开发综合篇 综合篇涉及到AT,LUA,SDK,LUA(sdk)开发,LUA和SDK开发会同步进行,后期再整理AT指令的 ...

  6. Python文学家为Python写的一首词?(附中英文版)

    The Zen of Python, by Tim Peters (Python之禅 by Tim Peters) Beautiful is better than ugly. (优美胜于丑陋(Pyt ...

  7. WebService与CXF

    一:Webservice 1:WebService是干什么的?有什么用? 一言以蔽之:WebService是一种跨编程语言和跨操作系统平台的远程调用技术. 所谓跨编程语言和跨操作平台,就是说服务端程序 ...

  8. Deep Learning(深度学习)学习笔记整理系列之(一)(转)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0  2013-0 ...

  9. Mysql8.0的登录大坑……(忘记登录密码也可以这么搞)

    关于安装和使用就不说了,属于基本操作了: 我来重点记录一下关于使用前,使用navicat登录的时候报错,1130和2059 查看安装后随机生成的密码: grep 'temporary password ...

  10. Linux mount 命令

    mount 命令用来挂载文件系统.其基本命令格式为:mount -t type [-o options] device dirdevice:指定要挂载的设备,比如磁盘.光驱等.dir:指定把文件系统挂 ...