Working With Promises in AngularJS Services

Let's talk about working with promises in AngularJS. To start, $q is a great implementation of promises, allowing you work with deferred objects and be more efficient with Ajax calls. $q api has few useful methods, first one is to create new deferred object using $q.defer(), so this object could be resolve in the future using $.q.defer().resolve and also to be reject using $.defer().reject methods. When executing Ajax calls from AngularJS services, usually we use $http which return by default a promise object which we can attach “then” method to for result notification. But when the service should fetch data from the backend and allow more than one AngularJS controllers to use, it doesn't make the make the most sense to fetch everything from the server every time. Then, we should save the data in local variable inside the service. So when...

Read more

Quick and Dirty JavaScript Closures Guide

This post covers the essentials of JavaScript Closures with many examples… Read more

Ways to Loop Over an Array in JavaScript

Ways to loop over an array in JavaScript? There are a multitude… Read more

== vs. === in Javascript (Abstract vs Strict equality in js)

== vs. === in JavaScript, understanding abstract vs. strict equality… Read more

How to empty an Array in JavaScript

This short posts describes different ways to empty a JavaScript Array… Read more

The Difference Between Ng-show vs. Ng-if

There are a variety of built-in Angular directives for showing and hiding… Read more

Why Use a Task Runner Like Gulp?

There are a lot of tasks involved with creating and deploying a… Read more

Three Quick Reasons to Learn Web Design

In today's world, having a powerful, professional-looking website is an essential for… Read more

How to Get Started With Backbone.js

Backbone.js is a very powerful Javascript library for front end development. Notice… Read more

How To Get Started With AngularJS

AngularJS is the one of the most powerful framework present for front… Read more