AngularJS - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

AngularJS API

AngularJS API

shape Description

API is nothing but Application Programming Interface. AngularJS API possess various global JavaScript functions that can perform certain tasks like:
  • Looping objects
  • Objects Comparison
  • Data Conversion
Developers can access API functions declared globally with the help of angular object. These functions can carry out low level JavaScript operations.
API Description
angular.lowercase() This API function changes a string to lowercase.
angular.uppercase() This API function changes a string to uppercase.
angular.isArray() This API function returns True if the reference is an array otherwise returns false.
angular.isFunction() This API function returns True if the reference is a array
angular.isString() This API function returns True if the reference is a string
angular.isNumber() This API function returns True if the reference is a number

shape Examples

Here is an AngularJS API example: [html] <!DOCTYPE html> <html> <head> <title>AngularJS API</title> <script data-require="angular.js@1.3.14" data-semver="1.3.14" src="https://code.angularjs.org/1.3.14/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script> <script src="App.js"></script> <script src="Controller.js"></script> </head> <body> <h1>AngularJS API</h1> <div ng-app="spApp" ng-controller="SPController"> <p>Default : {{ x1 }}</p> <p>lowercase : {{ x2 }}</p> <p>uppercase : {{ x3 }}</p> <p>isArray : {{ x4 }}</p> <p>isFunction : {{ x5 }}</p> <p>isString : {{ x6 }}</p> <p>isNumber : {{ x7 }}</p> </div> </body> </html> [/html] [javascript] var app = angular.module('spApp', []); app.controller('SPController', function($scope) { $scope.x1 = "Smith Watson"; $scope.x2 = angular.lowercase($scope.x1); $scope.x3 = angular.uppercase($scope.x1); $scope.x4 = angular.isArray($scope.x1); $scope.x5 = angular.isFunction($scope.x1); $scope.x6 = angular.isString($scope.x1); $scope.x7 = angular.isNumber($scope.x1); }); [/javascript] Output:

Summary

shape Key Points

  • lowercase(), uppercase(), isArray(), isFunction(), isString() and isNumber() are the various API functions.