I get this error thrown:
Error: Error: [$parse:isecwindow] Referencing the Window in Angular expressions is disallowed!
When I try using $window.open/window.open in angularjs.
Generate.html
<div class="print-report-footer" ng-show="vm.clicked">
<button type="button" class="btn btn-primary" ng-click="vm.downloadFile('pdf')">PDF</button>
<button type="button" class="btn btn-primary" ng-click="vm.downloadFile('xls')">XLS</button>
<button type="button" class="btn btn-primary" ng-click="vm.downloadFile('csv')">CSV</button>
</div>
Generate.ctrl.js
function downloadFile ( fileType ) {
var path = '/images/reports/DistrictSchoolReport.' + fileType;
return $window.open( path );
}
self.downloadFile = downloadFile;
This is the code that I have used. What do I need to do to avoid this error thrown everytime I use $window.open?
thisis being initialized aswindow.windowisn't testable,$windowisdownloadFilefunction is part of a controller. Seeing as you're using the controller as syntax, it should at least bethis.downloadFile = function...returnstatement