What are the AngularJs Global API?

Global API in AngularJS
API stands for Application Programming Interface. It is a set of protocols, routine and tools for building software application which allows the user to interact with the application and perform the several tasks.

In AngularJS Global API is a set of global Javascript functions used for performing tasks like comparing objects, iterating object, converting data.



Some API functions in AngularJS is shown below:

  • angular.lowercase: This converts the string into lowercase.

    Syntax:

    angular.lowercase(string);

    Example 1:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <html>
    <script src=
      </script>
      
    <body>
        <div ng-app="App" ng-controller="Ctrl">
            <p>{{"Before Conversion: " + i1 }}</p>
            <p>{{"After Conversion: " + i2 }}</p>
        </div>
        <script>
            var app = angular.module('App', []);
            app.controller('Ctrl', function($scope) {
                $scope.i1 = "GeeksforGeeks";
                // converting string into lowercase
                $scope.i2 = angular.lowercase($scope.i1); 
            });
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before Conversion: GeeksforGeeks                   
    After Conversion: geeksforgeeks                   
    
  • angular.uppercase: This converts the string into uppercase.

    Syntax:

    angular.uppercase(string);

    Example 2:

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <html>
    <script src=
      </script>
      
    <body>
        <div ng-app="App" ng-controller="Ctrl">
            <p>{{"Before Conversion: " + i1 }}</p>
            <p>{{"After Conversion: " + i2 }}</p>
        </div>
        <script>
            var app = angular.module('App', []);
            app.controller('Ctrl', function($scope) {
                $scope.i1 = "geeksforGeeks";
                // converting string into uppercase
                $scope.i2 = angular.uppercase($scope.i1); 
            });
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before Conversion: geeksforgeeks
    After Conversion: GEEKSFORGEEKS
    
  • angular.isString: This check the given value is a string or not, if the value is string then it returns true else it returns false.

    Syntax:

    angular.isString(value);

    Example

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <html>
    <script src=
      </script>
      
    <body>
        <div ng-app="App" ng-controller="Ctrl">
            <p>{{"Value is: " + i1 }}</p>
            <p>{{"Value is string: " + i2 }}</p>
        </div>
        <script>
            var app = angular.module('App', []);
            app.controller('Ctrl', function($scope) {
                $scope.i1 = 15;
                // checks whether the given value is a string
                $scope.i2 = angular.isString($scope.i1); 
            });
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Value is: 15
    Value is String: false
    
  • angular.isNumber: This checks whether the given value is number or not, if it is a number then it returns true else it returns false.

    Syntax:

    angular.isNumber(value);

    Example

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <html>
    <script src=
      </script>
      
    <body>
        <div ng-app="App" ng-controller="Ctrl">
            <p>{{"Value is: " + i1 }}</p>
            <p>{{"Value is string: " + i2 }}</p>
        </div>
        <script>
            var app = angular.module('App', []);
            app.controller('Ctrl', function($scope) {
                $scope.i1 = 15;
                // checks whether the given value is a number
                $scope.i2 = angular.isNumber($scope.i1); 
            });
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Value is: 15
    Value is Number: true
    
  • Some more APIs in AngularJS are given below:

  • angular.isDate: This checks whether the given value is date or not
  • angular.isArray: This checks whether the given reference is array or not
  • angular.isFunction: This checks whether the given reference is function or not
  • angular.isObject: This checks whether the given reference is a object or not


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.