AngularJs and CoffeeScript

Ok, now everybody know I love Java 8. But I also love CoffeeScript when it comes to web development. I think it is much easier to read than Javascript. Maybe its because I also love Ruby…

I also like AngularJs a lot. Despite the fact that it’s a full fledge framework (which I tend to dislike), I really enjoy using it. But I still have a lot to learn…

Now knowing that I love both Coffee and Angular, the first thing I tried, of course, was to use both.

Here’s what a Controller looks like:

I think its nice and easy to read. It uses the new “Controller as” syntax in Angular to better isolate the different scopes.

Be careful though: the html sample will work only if your web server converts coffee to js on the fly. Otherwise, you have to do the compilation on client side using coffee-script.js script.