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:


Some API functions in AngularJS are as follows:

1. angular.lowercase

Converts the string in lowercase.
Syntax

angular.lowercase(string);

Example

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

Output
Before Conversion: Intellipaat
After Conversion: intellipaat

Want to be ready for a Job? Check out our blog on Angular Interview Questions!

2. angular.uppercase

Converts the string in uppercase.
Syntax

angular.uppercase(string);

Example

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

Output
Before Conversion: Intellipaat
After Conversion: INTELLIPAAT

You can check our latest expertly-prepared guide on Postman interview questions to crack top-level MNC job interviews.

Full Stack Web Development Course Video:

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);

Example

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

Output
Value is: 22
Value is number: true

To learn more about Angular check out Intellipaat’s Angular Course.

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);

Example

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

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.

Check out our REST API Interview Questions guide to crack top-level MNC Interviews.

Course Schedule

Name Date Details
Web Development Courses 23 Mar 2024(Sat-Sun) Weekend Batch
View Details
Web Development Courses 30 Mar 2024(Sat-Sun) Weekend Batch
View Details
Web Development Courses 06 Apr 2024(Sat-Sun) Weekend Batch
View Details

Find Best AngularJS Training in Other Regions

Bangalore Hyderabad Chennai Mumbai