The differences between AngularJS $applyAsync and $evalAsync

A while ago I’ve written a blog post about “The differences between AngularJS $apply, $digest, and $evalAsync“. This blog post introduced the 3 methods and execution phases of AngularJS digest cycle.
Recently in AngularJS 1.3 and above AngularJS team introduced new scope function which calls $applyAsync.

AngularJS $applyAsync and $evalAsync

Within this blog post I will explore the similarities and differentiation between $AngularJS $applyAsync and $evalAsync.
Continue reading

AngularJS Services – Fetching Server Data

Fetching Server Data – Intro

$http in AngularJS is the service that assists us with fetching data from remote http services.
The simple way for using it is when you need data in a controller, then issue the $http call and use the data. This way works 100%, but as always our application is getting bigger…
If you do not manage your services you’ll find yourself writing the same http call dozens of times. If you want to avoid this (and you do!), then you can use AngularJS Services.

There are several ways for solving this problem via AngularJS Services. In this post, I’ll describe 2 ways for solving the reuse of $http.
1. One service endpoint for managing the entire http calls in our application.
2. One service for every model you have in your application.
This mean that you have several services.

AngularJS logo

AngularJS

Continue reading

AngularJS Services – Application Business Logic

Application Business Logic – Intro

As your application gets bigger you’ll see that you have several controllers, and every one of them controls a different part of your application. The most common usage of controllers is to communicate between the view side and the data/logic side of the application. It is a common mistake to want to put all your logic in the controller. In general, writing your logic in the controller is not recommended since the controller is better used for merging the data and the view.
The AngularJS developers thought about this, and created the AngularJS services for this task.

AngularJS logo

AngularJS

Continue reading

AngularJS Services

AngularJS Services are lazily instantiated singleton objects that be can used everywhere in your application. You can inject your services into your controllers, directives, and filters by specifying the name of the service in the declaration of your function.
Within this series of posts, we will explore the usages and benefits of the AngularJS Service provider.

AngularJS Services are created by the Injector service. The Injector service is one of the five types of “AngularJS recipes”.
You can read more about AngularJS providers.

AngularJS logo

AngularJS

Continue reading

AngularJS Services – Application Data Management

Application Data Management – Intro

In every medium-size application there are many data bindings between controllers, views, directives, and other application services. There are several ways to bind and store data across the application such as: using the $cacheFactory Service, or saving objects on the $rootScope. In my experience the best and most common way is to use the AngularJS Services.

You can either create one singleton object to store the entire application data, or to separate it into several services. In either case the AngularJS Services can easily give you the ability to share data across the entire application.

AngularJS logo

AngularJS

Continue reading