title: NFC Write Sample
body: <p>Please, i have a problem passing <code>$scope</code> data into an <code>nfc.write</code> function, but if i pass in a literal hard code value it write, i need sample solution of how to write users input data to an <code>NFC Tag</code>, All i have try was not successful, All i could do is to add from <code>$scope</code> users data.</p>
  
  <p>This is all i have done</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;ion-view view-title="Chats" data-ng-controller="chat as vm"&gt;
  &lt;ion-content&gt;
  
      &lt;div class="list"&gt;
          &lt;label class="item item-input"&gt;
              &lt;span class="input-label"&gt;Username&lt;/span&gt;
              &lt;input type="text" ng-model="userData.userName"&gt;
          &lt;/label&gt;
  
          &lt;label class="item item-input"&gt;
              &lt;span class="input-label"&gt;Description&lt;/span&gt;
              &lt;input type="text" ng-model="userData.description"&gt;
          &lt;/label&gt;
      &lt;/div&gt;
  
      &lt;fieldset style="clear:both;"&gt;
          &lt;input data-ng-click="login()" type="submit" name="submit"
                 value="Login" class="more blue" /&gt;
      &lt;/fieldset&gt;
  
      {{userData}}
  &lt;/ion-content&gt;
  </code></pre>
  
  <p></p>
  
  <h1>The Controller:</h1>
  
  <pre><code>.controller('chat', function($scope, $cordovaNfc) {
  
  $scope.loginData = {}; // This should get the data from view to be used below
  
  $cordovaNfc.then(function(nfc){
  
      // 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
      nfc.addNdefListener(function(nfcEvent){
  
          var tnf = ndef.TNF_EXTERNAL_TYPE,   
              recordType = "application/json", 
              payload = payloadData,                
              record,                               
              message = [
                 ndef.mimeMediaRecord(recordType, payload)  
              ];            
  
          nfc.write(
             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);
             }
          );
  
      }).then(
      //Success callback
      function(nfcEvent){
          console.log("bound success");
      },
      //Fail callback
      function(err){
          console.log("error");
          alert("error");
      });
     });
    })
  </code></pre>
  
  <p>Thanks.</p>