From http://briantford.com/blog/angular-phonegap.html