AngularJS API
- Previous Page AngularJS Validation
- Next Page AngularJS Includes
API is the abbreviation for Application Programming Interface (API).
AngularJS global API
AngularJS global API is a set of global JavaScript functions used to perform common tasks, such as:
- Compare objects
- Iterate over objects
- Convert data
Global API functions can be accessed by using the angular object.
Below is a list of some commonly used API functions:
API | Description |
---|---|
angular.lowercase() | Convert the string to lowercase. |
angular.uppercase() | Convert the string to uppercase. |
angular.isString() | If the reference is a string, it returns true. |
angular.isNumber() | If the reference is a number, it returns true. |
angular.lowercase() example
<div ng-app="myApp" ng-controller="myCtrl"> <p>{{ x1 }}</p> <p>{{ x2 }}</p> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.x1 = "BILL"; $scope.x2 = angular.lowercase($scope.x1); }); </script>
angular.uppercase() example
<div ng-app="myApp" ng-controller="myCtrl"> <p>{{ x1 }}</p> <p>{{ x2 }}</p> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.x1 = "Bill"; $scope.x2 = angular.uppercase($scope.x1); }); </script>
angular.isString() Example
<div ng-app="myApp" ng-controller="myCtrl"> <p>{{ x1 }}</p> <p>{{ x2 }}</p> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.x1 = "BILL"; $scope.x2 = angular.isString($scope.x1); }); </script>
angular.isNumber() Example
<div ng-app="myApp" ng-controller="myCtrl"> <p>{{ x1 }}</p> <p>{{ x2 }}</p> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.x1 = "BILL"; $scope.x2 = angular.isNumber($scope.x1); }); </script>
- Previous Page AngularJS Validation
- Next Page AngularJS Includes