2

I need to display the QR code image in the html using angularjs. I have a Qr code image in the rest controller and i need to display in the html using angularjs Here is my angularjs controller with directives used code:

$http.post("../rest/a/save").then(function(response){
            $scope.qrcode = response.data;
        });

Directive used

app.directive('avQr', function() {
    return {
        restrict: 'E',
        template: '',
        scope: {
                 image: '='
      },
      link: function(scope, elem, attr) {
            var qrImage = angular.element(scope.image);
            elem.append(qrImage);
      }
 }
})

In the html page tried with these to display got referenced from other suggestions and used it

<av-qr image="qrcode"></av-qr>
    <div ng-bind-html="qrcode"></div>
    <img data-ng-src='data:image/png;base64,{{qrcode}} />

But not working properly, from the rest controller i am sending the buffered image as response to the js controller.

Can anyone help to me solve this or any other suggestions.

5
  • what do you mean by not working properly? what is the error? What does this directive do? can you please be more descriptive. Commented Jan 22, 2018 at 9:49
  • i had referred this stackoverflow.com/questions/34400499/… and tried it Commented Jan 22, 2018 at 9:51
  • what type of data your api returns? refer to this : stackoverflow.com/questions/29780147/… Commented Jan 22, 2018 at 9:52
  • i have used the scope value in the directives in html Commented Jan 22, 2018 at 9:53
  • read the link that I have posted above, You will get your answer there. Commented Jan 22, 2018 at 10:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.