Guide to Creating and Consuming AngularJS APIs

What is API in Angular?

API (Application Programming Interface) in AngularJS is a set of global JavaScript functions used for the purpose of carrying out the common tasks such as comparing objects, iterating objects, converting data. Some API functions in AngularJS are as follows :

  • Comparing objects
  • Iterating objects
  • Converting data

Watch this What is Angular 8 video:

Video Thumbnail

Some API functions in AngularJS are as follows:

1. angular.lowercase

Converts the string in lowercase.
Syntax

angular.lowercase(string);<br>

Example

<!DOCTYPE html><br>
<html><br>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script><br>
<body><br>
<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl"><br>
<p>{{"Before Conversion: " +i1 }}</p><br>
<p>{{"After Conversion: " + i2 }}</p><br>
</div><br>
<script><br>
var app = angular.module('intellipaatApp', []);<br>
app.controller('intellipaatCtrl', function($scope) {<br>
$scope.i1 = "Intellipaat";<br>
$scope.i2 = angular.lowercase($scope.i1);  // convert string into lowercase<br>
});<br>
</script><br>
</body><br>
</html><br>

Output
Before Conversion: Intellipaat
After Conversion: intellipaat

Angular JS Expert

2. angular.uppercase

Converts the string in uppercase.
Syntax

angular.uppercase(string);<br>

Example

<!DOCTYPE html><br>
<html><br>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script><br>
<body><br>
<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl"><br>
<p>{{"Before Conversion: " +i1 }}</p><br>
<p>{{"After Conversion: " + i2 }}</p><br>
</div><br>
<script><br>
var app = angular.module('intellipaatApp', []);<br>
app.controller('intellipaatCtrl', function($scope) {<br>
$scope.i1 = "Intellipaat";<br>
$scope.i2 = angular.uppercase($scope.i1);  // convert string into lowercase<br>
});<br>
</script><br>
</body><br>
</html><br>

Output
Before Conversion: Intellipaat
After Conversion: INTELLIPAAT

Full Stack Web Development Course Video:

Video Thumbnail

3. angular.isNumber()

It checks that the given value is number or not. If value is number then it returns true otherwise returns false.
Syntax

angular.isNumber(value);<br>

Example

<!DOCTYPE html><br>
<html><br>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script><br>
<body><br>
<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl"><br>
<p>{{"Value is: " +i1 }}</p><br>
<p>{{"Value is number: " + i2 }}</p><br>
</div><br>
<script><br>
var app = angular.module('intellipaatApp', []);<br>
app.controller('intellipaatCtrl', function($scope) {<br>
$scope.i1 = 22;<br>
$scope.i2 = angular.isNumber($scope.i1);  // convert string into lowercase<br>
});<br>
</script><br>
</body><br>
</html><br>

Output
Value is: 22
Value is number: true

4. angular.isString()

It checks that the given value is string or not. If value is string then it returns true otherwise returns false.
Syntax

angular.isString(value);<br>

Example

<!DOCTYPE html><br>
<html><br>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script><br>
<body><br>
<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl"><br>
<p>{{"Value is: " +i1 }}</p><br>
<p>{{"Value is String: " + i2 }}</p><br>
</div><br>
<script><br>
var app = angular.module('intellipaatApp', []);<br>
app.controller('intellipaatCtrl', function($scope) {<br>
$scope.i1 = 22;<br>
$scope.i2 = angular.isString($scope.i1);  // convert string into lowercase<br>
});<br>
</script><br>
</body><br>
</html><br>

Output
Value is: 22
Value is String: false
Some more API is:

  • isDate – Determines if a value is a date.
  • isArray – Determines if a reference is anArray.
  • isFunction – Determines if a reference is aFunction.
  • isObject – Determines if a reference is aobject etc.

About the Author

Software Developer | Technical Research Analyst Lead | Full Stack & Cloud Systems

Ayaan Alam is a skilled Software Developer and Technical Research Analyst Lead with 2 years of professional experience in Java, Python, and C++. With expertise in full-stack development, system design, and cloud computing, he consistently delivers high-quality, scalable solutions. Known for producing accurate and insightful technical content, Ayaan contributes valuable knowledge to the developer community.