我刚刚发布这个小提琴,认为它可能对像我这样的人有帮助.它显示了如何将普通的javascript传递给角度范围.在这种情况下,范围获取窗口内部化信息.
http://jsfiddle.net/spacm/HeMZP/
为了个人使用,我将传递给角度范围这些信息:
使用navigator.platform变量
function isInIFrame(){
return window.location !== window.parent.location;
}
function updateMediaInfoWH() {
if((typeof(mediaInfo.inIFrame)!='undefined') && (!mediaInfo.inIFrame)) {
mediaInfo.width = innerWidth;
mediaInfo.height = innerHeight;
updateMediaInfoOrientation();
}
tellAngular();
}
function tellAngular() {
console.log("tellAngular");
var domElt = document.getElementById('mainContainer');
scope = angular.element(domElt).scope();
console.log(scope);
scope.$apply(function(){
scope.mediaInfo = mediaInfo;
scope.info = mediaInfo.width;
});
}
Run Code Online (Sandbox Code Playgroud)
欢迎任何评论.
我希望我的应用程序在指定的位置写入一个文件,因此如果需要创建适当的目录。create dir 操作对我来说不是问题,但我需要 dir 路径。我可以从文件路径中提取 if,但也许有一种快速/简洁/方便的方法来完成整个操作?
我再说一遍,我不是在搜索基本的 makedir 函数,而是使用一个可能不存在的文件的文件名,或者一个简单的 qt 函数来从文件路径字符串中提取 dir 路径字符串,所以我没有为这样一个基本任务编写一个函数。