Using AngularJS to generate PDF objects

I have an angular controller that fetches json from my server and dynamically shows them. The code is:

    <div ng-controller="myImgController">
      <div ng-repeat="img in imgs">
        <div ng-repeat="i in img">
          <img ng-src="{{i.id}}"/>
        </div>
      </div>
    </div>

How can I replicate this in terms of dynamically generating markup to show pdfs within the browser. The current code is:

    <div ng-controller="myNewPdfController">
      <div ng-repeat="pdf in pdfs">
        <div ng-repeat="p in pdf">
          <object ng-attr-data="{{p.id}}" type="application/pdf" width="100%" height="100%"></object>
        </div>
      </div>
    </div>

But i’m having problems as ng-attr-data / ng-src does not work in respects to changing the source of the pdf document. Just in case you were wondering, the p.id is the url of the pdf.

Can anyone suggest a solution? Theres a lot of stuff out but I thought i’d make a clear question for other people with the same problem.


Source: javascript

Leave a Reply