AngularJS API

This section introduces you to Some common APIs in AngularJS.

The API means A pplication P rogramming I nterface (application programming interface).


AngularJS Global API

The AngularJS global API is used to perform a collection of JavaScript functions for common tasks, such as:

  • Compare objects
  • Iterative object
  • Transform the object

The global API function is accessed using the angular object.

Here are some common API functions:

Api Describe
angular.lowercase() The conversion string is small case
angular.uppercase() The conversion string is capital
angular.isString() Determines whether a given object is a string and true if it is returned.
angular.isNumber() Determines whether a given object is a number and true if it is returned.

angular.lowercase()

< 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 = "JOHN";
$scope.x2 = angular.lowercase($scope.x1);
});
< /script >

try it "

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 = "John";
$scope.x2 = angular.uppercase($scope.x1);
});
< /script >

try it "

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 = "JOHN";
$scope.x2 = angular.isString($scope.x1);
});
< /script >

try it "

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 = "JOHN";
$scope.x2 = angular.isNumber($scope.x1);
});
< /script >

try it "