Click here for TL;DR
As I am learning some of the new features of ES6 it has gotten me thinking about how we are currently using them is ES5. Specifically Promises. Using Promises in ES5 has been made possible by several libraries out there. Most known would be the q library by Kris Kowal. Because of my love for, and general focus on, Angular I want to talk a little about the $q Service and using Promises in AngularJS.
Using Promises in AngularJS
It is important to note that Angular’s $q Service does not actually contain Kris Kowal’s q library. However like Kris’s library it allows us to write Promises in ES5. I have seen Promises used in Angular many different ways. I wanted to touch upon how I use them and why.
What is a Promise
Learn to Access HTTP Response Headers In Your AngularJS $http Request
Having been playing around with Angular for over 2 years, I found myself recently – for the first time – needing to access HTTP response headers in the success callback of my Angular $http request.
Looking around I found very little documentation on this so I thought I would write a short article.
First let’s look at a typical $http request:
Welcome to Strange Milk I’m hoping to turn this blog into a resource for other developers to use for problem solving, learning, brainstorming, and much more. I am going to start posting about what’s relevant to me and what I’m doing at that point in my life (front-end software specific). So I’d imagine there will be a lot of AngularJS in the near future….
Anyway, I hope this ends up being a valuable resource to many people to come, talk to you guys (and gals) soon!
P.S. I’m hoping to offer one tip per post, so might as well start that right away.
Pro Tip: Chrome Has DOM Breakpoints
You can insert breakpoints on your DOM that are triggered on: Node Removal, Subtree Modifications, or Attribute Modifications. Once inside your dev tools panel and the “Elements” tab, right click on any node and navigate to “Break On…” at the bottom of the menu!