Angular.js API


The AngularJS supports API(Application Programming Interface) which is a set of global JavaScript functions to perform the common actions such as comparing objects, iterating objects, converting data.

 

The below are the API functions supported  in the angularJS

 

API function Description
angular.uppercase() Convert string into Uppercase.
angular.lowercase() Convert string into Lowercase.
angular.isNumber()  Checks if the whether input is number or not if number then return true otherwise false.
angular.isString() Checks if the whether input is string or not if string then return true otherwise false.
isFunction() Regulates if a reference is a Function.  
isObject() Regulates if a reference is a Object. 
isDate() Regulates if a value is a Date. 
isArray() Regulates if a reference is a an Array.

 


Syntax Uppercase()

 

angular.uppercase(string);



Example


<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

</head>

<body>

<div ng-app="angularupperApp" ng-controller="angularupperCtrl">

{{"Initial string: " + U1 }}

{{"After uppercase() applied: " + U2 }}

</div>

<script> var app = angular.module('angularupperApp', []);
app.controller('angularupperCtrl', function ($scope) {
$scope.U1 = "uppercase";
$scope.U2 = angular.uppercase($scope.U1); // convert string into uppercase
});
</script>

</body>

</html>


 View Result   




Syntax Lowercase()


angular.lowercase(string);

 

Example

 

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

</head>

<body>

<div ng-app="angularlowerApp" ng-controller="angularlowerCtrl">

{{"Initial string: " + U1 }}

{{"After lowercase() applied: " + U2 }}

</div>

<script> var app = angular.module('angularlowerApp', []);
app.controller('angularlowerCtrl', function ($scope) {
$scope.U1 = "LOWERCASE";
$scope.U2 = angular.lowercase($scope.U1); // convert string into lowercase
});
</script>

</body>

</html>


 View Result   




Syntax isNumber(value)


angular.isNumber(value);


Example


<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

</head>

<body>

<div ng-app="checknumberapp" ng-controller="checknumberCtrl">

{{"Input is: " + n1 }}

{{"Is input number: " + n2 }}

</div>

<script> var app = angular.module('checknumberapp', []);
app.controller('checknumberCtrl', function ($scope) {
$scope.n1 = 99;
$scope.n2 = angular.isNumber($scope.n11); // convert input into number
});
</script>

</body>

</html>


 View Result   




Syntax isString(value)

 

angular.isString(value);



Example


<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

</head>

<body>

<div ng-app="checkstringapp" ng-controller="checkstringCtrl">

{{"Input is: " + n1 }}

{{"Is input number: " + n2 }}

</div>

<script> var app = angular.module('checkstringapp', []);
app.controller('checkstringCtrl', function ($scope) {
$scope.n1 = 99;
$scope.n2 = angular.isString($scope.n11); // convert input into string
});
</script>

</body>

</html>


 View Result   



In the next chapter you will learn about services and how to use it  in the angular.