AngularJS API
API stands for Application Programming Interface (Application Programming Interface).
AngularJS Global API
The AngularJS Global API is a collection of JavaScript functions for performing common tasks, such as:
- Comparing objects
- Iterating objects
- Transforming objects
Global API functions are accessed using the angular object.
Below is a list of some common API functions:
API | Description |
---|---|
angular.lowercase (<angular1.7) <br>angular.$$lowercase() (angular1.7+) | Converts a string to lowercase |
angular.uppercase() (<angular1.7) <br>angular.$$uppercase() (angular1.7+) | Converts a string to uppercase |
angular.isString() | Checks if the given object is a string, returns true if it is. |
angular.isNumber() | Checks if the given object is a number, returns true if it is. |
Note: The angular.lowercase and angular.uppercase methods were removed after AngularJS 1.7, replaced by angular.$$lowercase and angular.$$uppercase.
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 = "tutorialpro";
$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 = "tutorialpro";
$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 = "tutorialpro";
$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 = "tutorialpro";
$scope.x2 = angular.isNumber($scope.x1);
});
</script>