Within the code snippet provided below, there exists a hyperlink that triggers the opening of a PDF generated by Spring in a new browser window upon user interaction. However, certain users may have their pop-up blockers activated in their browsers. What specific modifications are required in the following code to ensure that the PDF opens IN THE SAME BROWSER WINDOW when the link is clicked? Please take note that this PDF is generated via a spring controller.
The HTML snippet is as follows:
<p><a ng-click="getPdf()">Show PDF</a></p>
Below is the Angular controller code:
angular.module('message', ['auth']).controller('message', function($scope, $http, $sce, auth) {
$scope.authenticated = function() {
return auth.authenticated;
}
$scope.getPdf = function(){
$http.get('/api/some-pdfr', {responseType: 'arraybuffer'})
.success(function (data) {
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});
}
});