js好用代码(217) 发表于 2017-02-28 | 分类于 CSS & JS js(判断俩对象属性是否相同)123456789101112131415161718192021222324252627function IsPropertyEqual(obj1, obj2) { if (obj1 === obj2) { return true; } if (!(obj1 instanceof Object) || !(obj2 instanceof Object)) { return false; } for (var p in obj1) { if (obj1.hasOwnProperty(p) && !obj2.hasOwnProperty(p)) { return false; } } for (p in obj2) { if (obj1.hasOwnProperty(p) && !obj2.hasOwnProperty(p)) { return false; } } return true;}function IsStructer(data, obj) { return IsPropertyEqual(obj, JSON.parse(data));} angular(文件选取)1234567891011121314151617181920<input type="file" fileread="app.js" />.directive("fileread", [function () { return { scope: { fileread: "=" }, link: function (scope, element, attributes) { element.bind("change", function (changeEvent) { scope.$apply(function () { scope.fileread = changeEvent.target.files[0]; }); var reader = new FileReader(); reader.onload = function (etc) { etc.target.result; //reader.readAsText(scope.fileread); }); } }}]); 文件下载(超好用,本地下载类型的)http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js