forked from ninapratiwi/ng-form-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng-form-data.min.js
6 lines (6 loc) · 1.33 KB
/
ng-form-data.min.js
1
2
3
4
5
6
/*! ng-form-data - v 0.0.1 - Fri Mar 14 2014 14:05:10 GMT+0800 (CST)
* https://github.com/tomchentw/ng-form-data
* Copyright (c) 2014 [tomchentw](https://github.com/tomchentw);
* Licensed [MIT](http://tomchentw.mit-license.org)
*/
(function(){var t,e={}.toString;t="FileWithFormDataInterceptor",angular.module("ng-form-data",[]).directive("input",function(){function t(t,e,n,i){var r;r=i||{$setViewValue:angular.noop},r.$open=function(){e[0].click()},e.on("change",function(){var e;e=this.files,t.$apply(function(){r.$setViewValue(n.multiple?e:e[0])})})}return{restrict:"E",require:"?ngModel",compile:function(e,n){return"file"===n.type?t:void 0}}}).config(["$httpProvider"].concat(function(e){e.interceptors.push(t)})).factory(t,["$window"].concat(function(t){function n(t,e){return t.length&&(e="["+e+"]"),t+""+e}function i(e){return this._d=new t.FormData,this._v=!1,this._e(e.data,""),this._v&&(delete e.headers["Content-Type"],e.data=this._d,e.transformRequest=angular.identity),e}return i.prototype._e=function(t,i){var r=this;angular.forEach(t,function(t,a){switch(a=n(i,a),e.call(t).slice(8,-1)){case"File":case"Blob":r._v=!0;break;case"Function":return;default:if(angular.isObject(t))return r._e(t,a)}r._d.append(a,t)})},{request:function(t){return"GET"===angular.uppercase(t.method)?t:"FormData"===e.call(t).slice(8,-1)?t:new i(t)}}}))}).call(this);