The above code worked for me in angular 2+ application
The notable edits I made to work:
changed from
var file = new Blob([result.data], {type: 'application/pdf'});
to
var file = new Blob([result], {type: 'application/pdf'});
and
from this
$http.get('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', { responseType: 'arraybuffer' }).then(function (response) {
return response;
});
to
$http.get('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', { responseType: 'arraybuffer' });