NFC Write Sample

Please, i need sample solution of how to write users input data to an NFC Tag, All i have try was not successful, All i could do is to add code the users data.

This is all i have done


<ion-view view-title="Chats" data-ng-controller="chat as vm">

    <div class="list">
        <label class="item item-input">
            <span class="input-label">Username</span>
            <input type="text" ng-model="userData.userName">

        <label class="item item-input">
            <span class="input-label">Description</span>
            <input type="text" ng-model="userData.description">

    <fieldset style="clear:both;">
        <input data-ng-click="login()" type="submit" name="submit"
               value="Login" class="more blue" />


The Controller:

.controller(‘chat’, function($rootScope, $scope, $cordovaNfc, Chats, nfcService) {

$scope.loginData = {};


    // I need to find a way to pass in the userData this point
    console.log($scope.loginData); // Here am not getting the data;
    var payloadData = $scope.loginData; // And i did get anything in the payload

    //Use the plugins interface as you go, in a more "angular" way

        var tnf = ndef.TNF_EXTERNAL_TYPE,   
            recordType = "application/json", 
            payload = payloadData,                
            message = [
               ndef.mimeMediaRecord(recordType, payload)  

           message,   // write the record itself to the tag
           function (success) { 
               console.log("Wrote data to tag.");
           // this function runs if the write command fails:
           function (reason) {
               alert("There was a problem " + reason);

    //Success callback
        console.log("bound success");
    //Fail callback



I will appreciate if someone could please give me a simple sample that can pass the scope data to the nfc.write.


Hey i tested something like this:

i built a gist for you… keep in mind i was using com.chariotsolutions.nfc.plugin plugin

Thanks for your response, I so much appreciate it, I will look into it and work on it.


One things i noticed from the example posted,

  1. The write payload return undefined
  2. The write section of the nfc.write console.log(‘written’); is not being triggered, so i added alert(‘written’); nothing happen.

Please help me review it, because i need the callback function to process other functions.