Giter VIP home page Giter VIP logo

angular-qr's Introduction

angular-qr v0.2.0 Build Status

QR code generator for AngularJS

Demo

Check out http://janantala.github.io/angular-qr/demo/

Requirements

  • AngularJS v 1.0+
  • qrcode.js (bower install qrcode is installed with angular-qr as dependecy)

Usage

We use bower for dependency management. Add

dependencies: {
    "angular-qr": "latest"
}

To your bower.json file. Then run

bower install

This will copy the angular-qr files into your bower_components folder, along with its dependencies. Load the script files in your application:

<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<script type="text/javascript" src="bower_components/qrcode/lib/qrcode.min.js"></script>
<script type="text/javascript" src="bower_components/angular-qr/angular-qr.min.js"></script>

Add the ja.qr module as a dependency to your application module:

var myAppModule = angular.module('MyApp', ['ja.qr']);

Directive

$scope.string = 'YOUR TEXT TO ENCODE';
<qr text="string"></qr>
<qr type-number="8" correction-level="'M'" size="200" input-mode="'ALPHA_NUM'" text="string" image="true"></qr>

Required attributes

text

Your text to encode from variable in the scope. If you want to encode text directly you need to escape it text="'YOUR TEXT TO ENCODE'".

Optional attributes

type-number

  • 1-40
  • default value: 0 = minimal required version

correction-level

  • L - Low
  • M - Medium (default)
  • Q - Quartile
  • H - High

size

Size in pixels

  • default value: 250

input-mode

  • NUMBER: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • ALPHA_NUM: *0–9, A–Z (upper-case only), space, $, %, , +, -, ., /, :
  • 8bit: ISO 8859-1
  • default value: minimal required input mode based on input text

image

  • If you want to render qr code into image element set this attribute to true.

Contributing

Contributions are welcome. Please make a pull request against canary branch, use Git Commit Message Conventions and do not bump versions. Also include tests.

Testing

We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use gulp:

npm install -g gulp
npm install
bower install
gulp

The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in karma.conf.js

License

The MIT License

Copyright (c) 2014 Jan Antala

angular-qr's People

Contributors

irjudson avatar janantala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-qr's Issues

ng-if is not working for me. I had to use ng-show instead...

In the directive, here is the line I had to use, for the template, to make it work:

<canvas ng-hide="image"></canvas><img ng-show="image" ng-src="{{canvasImage}}"/>

This is not really great in term of performance...

With the ng-if, the canvas and the image were shown. Actually the ng-if was not working for me...

Requires 1.2 version of angular

I'm using 1.3 in my project, could angular dependency be something like "angular": ">=1" if module really should work on any 1.x version?

Change color of QR?

Hi there...

In the proyect I'm working we need to change the color of the QR. Is there an option to do this??

Thanks

Error when trying to use directive with angular 1.3

Trying to make simple QR code failed.

<qr text="ABC"></qr>

Error: The `text` attribute is required.
    at postlink (build/debug/vendor/angular-qr/angular-qr.js:98:17)
    at build/debug/vendor/angular/angular.js:6923:44
    at nodeLinkFn (build/debug/vendor/angular/angular.js:6515:13)
    at compositeLinkFn (build/debug/vendor/angular/angular.js:5926:15)
    at publicLinkFn (build/debug/vendor/angular/angular.js:5831:30)
    at build/debug/vendor/angular-ui-router/release/angular-ui-router.js:2805:9
    at nodeLinkFn (build/debug/vendor/angular/angular.js:6515:13)
    at compositeLinkFn (build/debug/vendor/angular/angular.js:5926:15)
    at publicLinkFn (debug/vendor/angular/angular.js:5831:30)
    at updateView (build/debug/vendor/angular-ui-router/release/angular-ui-router.js:2733:23) <qr text="ABC" class="ng-scope ng-isolate-scope"> 

Error: [$injector:modulerr]

angular.js:4631 Uncaught Error: [$injector:modulerr] Failed to instantiate module poll due to:
Error: [$injector:modulerr] Failed to instantiate module ja.qr due to:
Error: [$injector:nomod] Module 'ja.qr' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

in my bower components i have qrcode ,qrcode.js and angular-qr

solve as possible as fast

Download QR code image

I was wondering if could download the generated QR code as an image, I am using ionic framework and could not found hot this can be done.

Does not work in environment with require.js

On our page we use both angular and require.js. This package depends on qrcode.js setting its main function in global, but in presence of define, qrcode.js exports itself as a module. Alas angular-qr tries to call undefined, which tends not to work.

Or I'm doing something wrong, which is always an option.

scope variable isnot recognized as valid text

Directive:
scope.qrData = 'http://' + scope.assignedIp + ':8002/#/instrumentState';

"scope.assignedIP" is the current assigned IP of the PC.

HTML:
<qr size="100" text="qrData"></qr>

Error:
Error: The text attribute is required.
at Object.postlink [as link]

Findings so far:
I have tried several other scope variables on this page and none of these is working.
A simple String is working. (<qr size="50" text="'simpleString'"></qr>).
So I guess, I installed the package correctly.

Error: The `text` attribute is required. Not working in Promise.

Problem

.controller('QrcodeCtrl', function ($scope, $stateParams, Post) {
            $scope.box = {};

            Post.qrcode($stateParams.postId).success(function(data) {
                $scope.post = data;
            });
        })

I've tried $rootScope also nothing works in a promise.
View:

<qr text="post.qrcode" size="size"></qr>

Works

.controller('QrcodeCtrl', function ($scope, $stateParams) {

            $scope.qrcode = 'test';
        })

View:

<qr text="qrcode" size="size"></qr>

Error: The `text` attribute is required.

I keep receiving these errors:

Error: The text attribute is required.
at link (http://localhost:8000/bower_components/angular-qr/angular-qr.min.js:6:1380)
at U (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:48:226)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:309)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:41:371
at http://localhost:8000/app/lib/angular/angular.js:1304:27
at g.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:98:272)
at g.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:99:48)
at http://localhost:8000/app/lib/angular/angular.js:1302:15 angular.js:8296
Error: The text attribute is required.
at link (http://localhost:8000/bower_components/angular-qr/angular-qr.min.js:6:1380)
at U (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:48:226)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:309)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:41:371
at http://localhost:8000/bower_components/angular/angular.js:1304:27
at g.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:98:272)
at g.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:99:48)
at http://localhost:8000/bower_components/angular/angular.js:1302:15 angular.js:8296
Error: The text attribute is required.
at link (http://localhost:8000/bower_components/angular-qr/angular-qr.min.js:6:1380)
at U (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:48:226)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:309)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at k (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:42:326)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:41:371
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:17:364
at g.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:98:272)
at g.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:99:48)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js:17:320 angular.js:8296

Any idea?

Does not work inside ng-repeat

<!DOCTYPE html>
<html ng-app="APP">
<head>
    <meta charset="UTF-8">
    <title>angular-qr example</title>

</head>
<body>
    <div ng-repeat="x in ['hello', 'world']">
      <qr type-number="0" correction-level="'M'" size="200" input-mode="'ALPHA_NUM'" text="{{x}}"></qr>
    </div>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
    <script src="/application/html/js/janantala/angular-qr/qrcode.js"></script>
    <script src="/application/html/js/janantala/angular-qr/angular-qr.js"></script>

    <script>
    angular.module("APP",["ja.qr"])
    </script>
</body>
</html>

TypeError: t is not a function with random img

So I´m using the qr tag and a wild random image appear.

/*TEAM CONTROLLER*/
function TeamCtrl($scope, $localStorage) {
  $scope.user = $localStorage.getObject("user");
  console.log($scope.user);

  $scope.qrcodeString = $scope.user.team;

  console.log($scope.qrcodeString);

}
TeamCtrl.$inject = ['$scope', '$localStorage'];

screen shot 2016-01-31 at 12 28 47 am

<ion-view view-title="Team">
  <ion-content>

    <h1>Hola</h1>
    <qr type-number="8" correction-level="'M'" size="200" input-mode="'AUTO'" text="qrcodeString" image="true"></qr>

  </ion-content>
</ion-view>

QR code not working

l got the code appearing however my scanner won't pick it up but picks other codes up.

the code is below

any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.