legalthings / angular-pdfjs-viewer

PDF.js viewer directive for AngularJS
MIT License
137 stars 113 forks source link

no resource to load, early way out #51

Closed LYXmoonstars closed 7 years ago

LYXmoonstars commented 7 years ago

I use data, In the case that you cannot simply use the URL of the pdf, you can pass in raw data as a Uint8Array object. The data attribute takes a scope variable as its argument.

$scope.data = null; // this is loaded async

$http.get("http://example.com/file.pdf", {
    responseType: 'arraybuffer'
}).then(function (response) {
    $scope.data = new Uint8Array(response.data);
});

$scope.data have database,but i use <pdfjs-viewer data="$ctrl.data"></pdfjs-viewer> in html,not pdf view ,Prompt: "no resource to load, early way out". I need your help, thank you.

LYXmoonstars commented 7 years ago

I will data="$ctrl.data" override data="data",The PDF file is displayed.

jasny commented 7 years ago

Read https://stackoverflow.com/questions/11605917/this-vs-scope-in-angularjs-controllers