XHR and Server side communication using AngularJS

Angular comes bundled with a wrapper around the XMLHttpRequest (abbreviated as XHR) called $http. We use $http to make AJAX requests. The $http object is a library that helps you make HTTP requests and then parse the response. Let’s understand $http with an example. Consider the following code:

If we run the above code, it will make…

Understanding transclusion in AngularJS

Of all the concepts in AngularJS, many developers find transclusion to be complex and difficult to understand. In this post, let’s take a deep dive into it with a simple example. The document from http://docs.angularjs.org/guide/directive says: transclude – compile the content of the element and make it available to the directive. Typically used with ngTransclude.…

Understanding Filters in AngularJS

Filters help us in changing/modifying the data. AngularJS provides us a number of inbuilt filters; along with the capability to create our own custom filters. A filter is similar to a factory or service in many ways but comes with an added advantage of behaving on a global scope, once created. We can invoke a filter on both the data…

Event Propagation in AngularJS

Apart from being able to use in-built directives like ng-click to handle DOM events, AngularJS also allows us to create our own events and propagate them to other controllers. Consider an example where you would like to make an AJAX call to retrieve some data from an API. Now, assume you have a controller that fetches…