javascript - $window in angular.js throws exception when using $window.open -
i error thrown:
error: error: [$parse:isecwindow] referencing window in angular expressions disallowed!
when 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 code have used. need avoid error thrown everytime use $window.open?
you running $window.open() view. instead: (don't use return)
function downloadfile ( filetype ) { var path = '/images/reports/districtschoolreport.' + filetype; $window.open( path ); }
Comments
Post a Comment