How can I protect my .factory from minification?

Samantha J T Star

I have this function in AngularJS. Can someone tell me how I can protect it so that it can be 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 the user, therefore not unique.
                deferred.reject("User name is taken");
            }, function () {
                // User not found, therefore unique!
                deferred.resolve();
            });
        return deferred.promise;
    }
});
Michael Cole

I think what you mean is to protect dependency injection of this function:

function (appConstant, $q, $http) {}

To do that, change it to an array, telling Angular what you are injecting:

['appConstant', '$q', '$http', function (appConstant, $q, $http) {}]

so it would look like this

.factory('isEmailAvailable', ['appConstant', '$q', '$http', function (appConstant, $q, $http) {
  // Your code here
}])

If you are using gulp to automate building your app (it's totally worth it), you can use the gulp-ng-annotate module to do this automatically without adding cruft to the original code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I protect my site from the multiple post requests?

From Dev

How can I protect my user passwords and passphrase from root

From Dev

How can I protect my site from the multiple post requests?

From Dev

How can I protect my OLED screen from burn-in?

From Dev

How can I protect my robot code?

From Dev

How can I protect my WebAPI from abuse and avoid sharing API keys?

From Dev

How can I protect my data from certain apps in Windows 7?

From Dev

How can I protect my php, jquery, ajax requests from hackers?

From Dev

How can I protect my Linux system from future ramsomware's attack?

From Dev

How can I protect my Kloudless API Key and Account ID?

From Dev

How can I protect my Kloudless API Key and Account ID?

From Dev

How can I protect a matrix in R from being altered by Rcpp?

From Dev

How can I protect integer data on NSUserDefaults from hacking?

From Dev

How can I protect sqlite db in android from being stolen

From Dev

How can i restrict protect_from_forgery with exception rails

From Dev

How can I protect integer data on NSUserDefaults from hacking?

From Dev

How can i protect a property from being overwritten

From Dev

How can i restrict protect_from_forgery with exception rails

From Dev

How can I protect my asp.net web api? I can not understand the template well

From Dev

How can I "protect" my public key in my .NET code once deployed?

From Dev

How can I make a backup of my factory-new computer?

From Dev

How can I factory reset my microSD card

From Dev

How can I use the Factory pattern to refactor my Java code?

From Dev

Can I hash/encrypt or otherwise protect emails in my Django app from hackers?

From Dev

How can I protect my source code when deploying on different computers

From Dev

How can I protect MVC Hangfire Dashboard

From Dev

How can I protect an API endpoint with PassportJS?

From Java

How can I obfuscate (protect) JavaScript?

From Dev

How can I protect a terminal command with confirmation?

Related Related

  1. 1

    How can I protect my site from the multiple post requests?

  2. 2

    How can I protect my user passwords and passphrase from root

  3. 3

    How can I protect my site from the multiple post requests?

  4. 4

    How can I protect my OLED screen from burn-in?

  5. 5

    How can I protect my robot code?

  6. 6

    How can I protect my WebAPI from abuse and avoid sharing API keys?

  7. 7

    How can I protect my data from certain apps in Windows 7?

  8. 8

    How can I protect my php, jquery, ajax requests from hackers?

  9. 9

    How can I protect my Linux system from future ramsomware's attack?

  10. 10

    How can I protect my Kloudless API Key and Account ID?

  11. 11

    How can I protect my Kloudless API Key and Account ID?

  12. 12

    How can I protect a matrix in R from being altered by Rcpp?

  13. 13

    How can I protect integer data on NSUserDefaults from hacking?

  14. 14

    How can I protect sqlite db in android from being stolen

  15. 15

    How can i restrict protect_from_forgery with exception rails

  16. 16

    How can I protect integer data on NSUserDefaults from hacking?

  17. 17

    How can i protect a property from being overwritten

  18. 18

    How can i restrict protect_from_forgery with exception rails

  19. 19

    How can I protect my asp.net web api? I can not understand the template well

  20. 20

    How can I "protect" my public key in my .NET code once deployed?

  21. 21

    How can I make a backup of my factory-new computer?

  22. 22

    How can I factory reset my microSD card

  23. 23

    How can I use the Factory pattern to refactor my Java code?

  24. 24

    Can I hash/encrypt or otherwise protect emails in my Django app from hackers?

  25. 25

    How can I protect my source code when deploying on different computers

  26. 26

    How can I protect MVC Hangfire Dashboard

  27. 27

    How can I protect an API endpoint with PassportJS?

  28. 28

    How can I obfuscate (protect) JavaScript?

  29. 29

    How can I protect a terminal command with confirmation?

HotTag

Archive