$window 角度.js在使用 $window.open 时引发异常
$window in angular.js throws exception when using $window.open
我得到这个错误:
Error: Error: [$parse:isecwindow] Referencing the Window in Angular expressions is disallowed!
当我尝试在angularjs中使用$window.open/window.open时。
生成.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;
这是我使用过的代码。我需要做什么来避免每次使用 $window.open 时引发此错误?
您正在从视图中运行$window.open()。请改为这样做:(不要使用返回)
function downloadFile ( fileType ) {
var path = '/images/reports/DistrictSchoolReport.' + fileType;
$window.open( path );
}
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- 直接下载文件,而不是从window.open(url)
- $window.ga在AngularJS事件中未定义
- 如何将PDF作为二进制文件传递到window.open()
- window.onload没有'无法在Android WebView中工作
- window.location替换并传递URL历史记录条目中的变量
- window.on.scroll事件未启动
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 为什么window.open不打开一个以变量形式给出的链接
- window.location使用jquery mobile实现chrome跳转
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- window.opener.document在ie中不起作用
- window.onpopstate不工作;当我导航回页面时,不会发生任何事情
- 未捕获的类型错误:topFrame.window.changeSelectedBarStyle不是函数,原因是什么
- window.location.replace :权限被拒绝和未捕获的异常
- 为什么 window.setTimeout 在 IE9 中引发异常
- "闭合的“;属性异常返回“;window.open”;在JavaScript&歌剧
- IE中window.location.href的异常行为
- 处理$window.localstorage中的异常日志记录
- $window 角度.js在使用 $window.open 时引发异常