ngCordova Released

So I know (think?) there is a significant portion of my audience who do not use Twitter, and for those of you who have avoided that trap (don’t let anyone fool you, it is a trap), you may have missed me recently raving about the Ionic Framework. Briefly, Ionic is a way to work with Cordova/PhoneGap apps using Angular directives. It has an incredible collection of UI and UX controls that can be helpful to you. I’m still new to Angular and I’ve found their controls easy to use. I plan on blogging about this a bit more later, but I wanted to tell you about something else these folks created – ngCordova.

ngCordova is a set of Angular directives focused on Cordova APIs. For folks who already use Angular, this provides an easier and more “Angular-ish” way to work with Cordova. As an example (and yes, I stole this right from the docs), here is how you would make use of the Camera API:



module.controller('PictureCtrl', function($scope, $cordovaCamera) {

  $scope.takePicture = function() {
    $cordovaCamera.getPicture({

      // See all the possible Camera options from the Camera docs [1]:
      /// https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md#cameraoptions

    }).then(function(imageData) {

      // Success! Image data is here

    }, function(err) {

      // An error occured. Show a message to the user

    });
  }

});

And here is a bar code example:


module.controller('MyCtrl', function($scope, $cordovaBarcodeScanner) {
  $cordovaBarcodeScanner.scan().then(function(result) {
    // Scanner result
  }, function(err) {
  });

As you can see, it is all promisy (yes, that is a new word) and a bit simpler to work with in my opinion. I’d like to see more of course (the File API really needs to be implemented as well – it needs promises bad) but it is off to a great start.

Check it out. And – oh yes – it is 100% free and open source!