Skip to content

Instantly share code, notes, and snippets.

View ocolot's full-sized avatar

Olivier Colot ocolot

View GitHub Profile
@ocolot
ocolot / url_shortener.coffee
Created July 23, 2013 12:50
Url Shortener (AngularJS service using Google UrlShortener API)
angular.module('AppServices')
.factory 'UrlShortener', ($q, $rootScope) ->
gapiKey = 'APP_KEY'
gapi_deferred = $q.defer()
gapi_loaded = gapi_deferred.promise
gapi.client.setApiKey(gapiKey)
gapi.client.load 'urlshortener', 'v1', ->
$rootScope.$apply ->
gapi_deferred.resolve('loaded')