Twitter: raymondcamden


Address: Lafayette, LA, USA

ngCordova Released

06-04-2014 6,218 views Mobile, JavaScript, HTML5 13 Comments

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!

13 Comments

  • Martin Cisneros #
    Commented on 06-04-2014 at 1:34 PM
    Wow! i just started learning Angular just because of Ionic and this is so good :) BTW im learning at codeschool.com the course is free and very well explained
  • Commented on 06-04-2014 at 1:40 PM
    I just tweeted that - hope you don't mind. :)
  • Martin Cisneros #
    Commented on 06-04-2014 at 2:13 PM
    No problem :) BTW i'm a part of your audience who do not use Twitter, i avoided the trap hehe, i have an account but i dont use it. Regards.
  • Commented on 06-04-2014 at 4:42 PM
    RSS4Lyfe
  • GFoley83 #
    Commented on 06-04-2014 at 5:39 PM
    Can it be used without Ionic? Can't seem to get it working.
  • Commented on 06-04-2014 at 6:44 PM
    According to the docs, you don't need it. But maybe I'm reading it wrong. I'd file a bug report on the Git repo (it is either a bug that the dependency isn't documented or a bug in - well whatever you did) and let us know back here please.
  • GFoley83 #
    Commented on 06-08-2014 at 3:16 PM
    Looks like you don't need Ionic but I haven't been able to stand up a there demo app (from the ngCordova repo) on PhoneGap yet. Geolocation works but not the camera or device or accelerometer, though I may just be missing something.
  • Commented on 06-08-2014 at 3:37 PM
    Did you file an issue on the GH repo?
  • Commented on 06-13-2014 at 3:32 AM
    I've used this one recently in an ionic project and it's very confortable. good job
  • FileAPI with promises #
    Commented on 08-06-2014 at 9:24 PM
    "the File API really needs to be implemented as well - it needs promises bad"
    Have a look at https://gist.github.com/kerrishotts/7147214 . It's FileAPI with q.js and it works great!
  • Commented on 08-06-2014 at 9:27 PM
    Slick, is that you Kerri? You didn't use a real name.
  • Commented on 08-22-2014 at 1:03 AM
    do you have a ebook for ngcordova? very hard to learn this. documentation wasnt good.
  • Commented on 08-22-2014 at 6:53 AM
    Nope - best I can suggest is to report bugs on their project for when things aren't documented clearly.

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty