Azure Mobile Services with AngularJS $resource

Microsoft released the ability to create custom APIs with Azure Mobile Services in June 2013 and released the JavaScript client for Azure Mobile Services (AMS) even earlier in March 2013. The JavaScript client is excellent and easy to use, but it doesn’t play well with AngularJS. Actually, that’s not true. It plays just fine with AngularJS but it requires you to use $scope.$apply() when you’re working with the data retrieved.…

Upload to Azure Storage REST API from Xamarin

It surprised me to find that uploading an image to Azure Storage using the REST API with Xamarin iOS wasn’t straightforward. After a lot of research and by combining a couple techniques, we can easily upload a UIImage to blob storage using the Azure Storage REST API. Here’s what you’ll need: Azure Mobile Services (and client library) HttpClient I’m not going over how to create a storage location and container nor an Azure Mobile Service.…

AngularJS and PlantLink

If you’ve ever had a houseplant die on you, pay attention. Eight months ago, my company, Heavy Code, started a gig with a local startup, Oso Technologies. I’d heard of this company months earlier when their Kickstarter campaign hit the news. They were building a product that would notify you when a plant in your house or garden needed more water. It’s called PlantLink and one day, they needed help with their AngularJS web app.…

No Pain AngularJS Directives

By now you’ve got your hands dirty with Angular and are starting to build some more complicated apps. You’ve read the documentation and the samples and know about these things called “directives”. But you’re afraid — afraid that they’re too complicated and difficult. Fear Not, My Friend It’s true that AngularJS directives can get pretty complicated, but they can also be pretty simple. Let’s build a really simple one that you might re-use over and over: a progress spinner.…

Medium Word Count Chrome Extension

The website Medium.com offers an excellent writing environment. One problem I always had with the service is that it doesn’t really keep track of how long a post is. Other services, such as Editorially, do keep track of the length. I prefer Medium’s writing mode to Editorially’s, but wanted to know how long my posts are. So I wrote a Chrome browser extension to solve this problem for me. It’s very simple and very subtle.…

TypeScript Generics

About a month ago, Microsoft released the 0.9 version of TypeScript. Originally released in October 2012, the language has come a long way and one of its most requested and recent additions is generics. You may find yourself asking, “When the heck am I going to use generics in JavaScript?” I had the same question. The answer is all the time!! Even If You Don’t Care Even if you don’t care about generics yourself, you’ll start to get benefits from the community.…

AngularJS and TypeScript

Lately, I’ve started using AngularJS instead of Knockout. Knockout.js is very popular in the .NET world, is very easy to use, and meshes well with .NET devs used to the MVVM style of development. I highly recommend it. But, yeah, it’s fair to say that I’m being a little fickle in deciding to switch. Ask me for a definitive reason and I’ll waffle something about having to create my own binding handlers in knockout.…

TypeScript and Knockout: Define Computed Observables

ko.computed() in TypeScript On my second day of figuring out how to use knockout.js and TypeScript, I came upon computed observables and ran into trouble. As a point of reference, this is a simplified version of how I declared my ViewModel in pure JavaScript: var SampleViewModel = function () { var self = this; self.propertyOne = ko.observable(); self.propertyTwo = ko.observable(); self.propertyThree = ko.computed(function () { return self.propertyOne() + self.propertyTwo(); }); }; This simple ViewModel has three properties.…

TypeScript not Rebuilding JavaScript File

UPDATE: While the solution I presented is fine for builds, what you really want is for the JavaScript file to be regenerated when you save the TypeScript file. The current TypeScript plug-in doesn’t do this. Lucky for us, Mads Kristensen has updated the Web Essentials 2012 plug-in to support TypeScript. It will rebuild your .ts files when you save them. This one is an easy fix. Here’s the situation: You downloaded and installed the TypeScript and opened up your existing ASP.…

TIL: Knockout View Models with jQuery Deferreds

I’m a knockout.js beginner and I’m no JavaScript Ninja. I’ve got a lot of habits that are carryovers from my years of C# and I sometimes find myself trying too hard to make those habits work in JavaScript when there are better ways. I learned how to use jQuery deferred objects and promises inside of a knockout view model. I was working on a project that relies heavily on knockout.js for data-binding and its MVVM awesomeness.…