Reputation: 703
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?
Upvotes: 0
Views: 1083
Reputation: 462
You are running $window.open() from the view. Do this instead: (don't use return)
function downloadFile ( fileType ) {
var path = '/images/reports/DistrictSchoolReport.' + fileType;
$window.open( path );
}
Upvotes: 5