Using the Global APIs

As you are implementing AngularJS applications, you will find that there are common JavaScript tasks that you need to perform regularly, such as comparing objects, deep copying, iterating through objects, and converting JSON data. AngularJS provides a lot of this basic functionality in the global APIs.

The global APIs are available when the angular.js library is loaded, and you can access them by using the angular object. For example, to create a deep copy of an object named myObj, you use the following syntax:

var myCopy = angular.copy(myObj);

The following code shows an example of iterating through an array of objects by using the forEach() global API:

var objArr ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.