angularjs - How can I protect my .factory from minification? -
i have function in angularjs. can tell me how can protect can minified:
.factory('isemailavailable', function (appconstant, $q, $http) { return function (email) { var deferred = $q.defer(); var url = appconstant.baseurl + '/api/user/existsbyemail'; $http({ url: url, method: "put", data: { email: email } }).then(function () { // found user, therefore not unique. deferred.reject("user name taken"); }, function () { // user not found, therefore unique! deferred.resolve(); }); return deferred.promise; } });
i think mean protect dependency injection of function:
function (appconstant, $q, $http) {} to that, change array, telling angular injecting:
['appconstant', '$q', '$http', function (appconstant, $q, $http) {}] so this
.factory('isemailavailable', ['appconstant', '$q', '$http', function (appconstant, $q, $http) { // code here }]) if using gulp automate building app (it's totally worth it), can use gulp-ng-annotate module automatically without adding cruft original code.
Comments
Post a Comment