Yo + Angular + Cordova = Yay!

Starting with Daniel Simard’s awesome grunt-angular-phonegap, I was able to get a Hello World (aka ‘Allo ‘Allo) cordova base app running on my Android simulator without much trouble. It didn’t quite work out of the box, and I am not sure yet how to contribute back, but until I figure that out, I thought I would share what I did to get things going.

cordova platform add android

To get ‘grunt serve’ to work, I had to copy platforms/android/assets/cordova*.js to app/

cp platforms/android/assets/www/cordova*.js app/

In Gruntfile.js, in the ‘build’ step, I commented out the ‘cdnify’ task which forces the app to load jquery from google’s CDN instead of locally. Added above the inclusion of jquery.js in app/index.html Created script/fscordova.js, from http://www.ng-newsletter.com/posts/angular-on-mobile.html#native Added above the inclusion of app.js Added fsCordova’ to things to inject in app.js after ‘ngRoute’. Listen to cordova ready within scripts/controller/main.js

angular.module(‘myappApp’)
.controller(‘MainCtrl’, function ($scope, CordovaService) {

CordovaService.ready.then(function() {
//console.log(“CORDOVA IS READY ———–”);
$(‘.text-muted’).html(“Woot Woot!”); //yes it’s jQuery… shoot me!
});

$scope.awesomeThings = [
‘HTML5 Boilerplate’,
‘AngularJS’,
‘Karma’
];
});

Now you can run

grunt phonegap:build serve

and more importantly:

grunt phonegap:build phonegap:emulate && platforms/android/cordova/log

Enjoy! Screen Shot 2013-12-12 at 11.29.10 PM