Ale*_*ber 5 javascript intervals angularjs cordova blackberry-10
在尝试记录$window.open()AngularJS中定义的窗口对象时,我遇到了相当奇怪的行为$interval
self = this
$scope.childWindow = $window.open(authService.buildAuthorizeUrl(), '_blank')
console.log $scope.childWindow
var1 = "I may not work"
self.var2 = 'I should work'
privateData.authInterval = $interval ->
console.log $scope.childWindow
console.log var1
console.log self.var2
,
1000
Run Code Online (Sandbox Code Playgroud)
产量
Window {document: document, window: Window, frameElement: null, clientInformation: Navigator, onhashchange: null…}
Window {}
I may not work
I should work
Window {}
I may not work
I should work
Run Code Online (Sandbox Code Playgroud)
如您所见,第一个console.log $scope.childWindow是输出完全定义的窗口对象.其中的所有其他内容$interval仅输出{}.我已经尝试不附加childWindow到该$scope对象,我已经尝试将其附加到self.我也尝试过这个例子并经历了相同的行为.任何人都知道为什么会这样吗?非常感谢.
JSFiddle演示:http://jsfiddle.net/U3pVM/15124/
我了解到,由于安全原因,这不应该在浏览器中工作,这可以解释为什么它会被“覆盖”。该用例实际上是在 Blackberry10 Cordova 应用程序中。要解决此问题,您必须禁用网络安全性,config.xml如下所示:
<access origin="*"/>
<preference name="websecurity" value="disable" />
Run Code Online (Sandbox Code Playgroud)
当然,*会将所有域列入白名单。要稍微加强安全性,请添加您想要列入白名单的域。
| 归档时间: |
|
| 查看次数: |
136 次 |
| 最近记录: |