Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check a function exist or not in Angularjs?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 757
    Comment on it

    Hello friends,

    Today we learn how to check a function exist or not. In angular js, IsFunction() is used to find out the function exist or not. If the function exists it returns true else it will return false.

    Syntax:

    angular.isFunction(value);

    value is the function name that we want to check. Let's take an example to understand it.

    <!DOCTYPE html>  
    <html ng-app="">    
    <head>  
    <title>AngularJS code</title>    
    <script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">    
    </script>    
        
    </head>    
    <body>  
    <fieldset>  
    <legend>AngularJS IsFunction()</legend>  
    <script>    
      
    function functionName()  
    {  
        return "function name";  
    }  
    var str = "new string obj";  
      
    document.write(angular.isFunction(functionName));    
    document.write("</br>");  
    document.write(angular.isFunction(str));   
        
    </script>  
    </fieldset>  
    </body>    
    </html>  

    Output of above is:

    true
    false

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: