AngularJS API
API stands forApplication Programming IApplication Programming Interface.
AngularJS Global API
The AngularJS Global API is a collection of JavaScript functions used to perform common tasks, such as:
- Comparing objects
- Iterating over objects
- Converting objects
Global API functions are accessed using the angular object.
The following lists some common API functions:
| API | Description |
|---|---|
| angular.lowercase (<angular1.7) angular.$$lowercase()(angular1.7+) |
Converts a string to lowercase |
| angular.uppercase() (<angular1.7) angular.$$uppercase()(angular1.7+) |
Converts a string to uppercase |
| angular.isString() | Determines whether the given object is a string, returns true if it is. |
| angular.isNumber() | Determines whether the given object is a number, returns true if it is. |
Note:Since AngularJS 1.7, the angular.lowercase and angular.uppercase methods have been removed, 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 = "EXAMPLE";
$scope.x2 = angular.$$lowercase($scope.x1);
});
</script>
Try it Yourself »
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 = "example";
$scope.x2 = angular.$$uppercase($scope.x1);
});
</script>
Try it Yourself »
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 = "EXAMPLE";
$scope.x2 = angular.isString($scope.x1);
});
</script>
<p>{{ x1 }}</p>
<p>{{ x2 }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.x1 = "EXAMPLE";
$scope.x2 = angular.isString($scope.x1);
});
</script>
Try it Yourself »
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 = "EXAMPLE";
$scope.x2 = angular.isNumber($scope.x1);
});
</script>
<p>{{ x1 }}</p>
<p>{{ x2 }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.x1 = "EXAMPLE";
$scope.x2 = angular.isNumber($scope.x1);
});
</script>
Try it Yourself »