Neither angular-qr nor angular-qrcode worked for me, so I ended up quickly flipping my own directive based on Shim Sangmin's QRMode generator library :
<script src="lib/qrcode.js/qrcode.js"></script>
-
.directive('qrcode', function($interpolate) {
return {
restrict: 'E',
link: function($scope, $element, $attrs) {
var options = {
text: '',
width: 128,
height: 128,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: 'H'
};
Object.keys(options).forEach(function(key) {
options[key] = $interpolate($attrs[key] || '')($scope) || options[key];
});
options.correctLevel = QRCode.CorrectLevel[options.correctLevel];
new QRCode($element[0], options);
}
};
});
Then use it like this:
<qrcode text="{{something.on.scope}}" color-bright="#ff0000"></qrcode>
Edit: check this out on JSFiddle .
source
share