Closed daveLC closed 7 years ago
Having set up a basic cordova angular app and importing the ngCordova-nfc module, the following controller:
angular.module("RetailerApp.controllers.Main", ['ngCordova.plugins.nfc']) .controller('MainController', function($scope, $cordovaNfc) { $cordovaNfc.then(function(nfcInstance){ nfcInstance.addNdefListener(function(event) { $scope.customerId = getCustomerIdFromNfcTag(event.tag); alert ("Customer id read: " + $scope.customerId); $scope.customerDiv = true; }); }); }); var getCustomerIdFromNfcTag = function (tag) { var ndefMessage = tag.ndefMessage; var fullMessage = JSON.stringify(ndefMessage); var payload = nfc.bytesToString(ndefMessage[0].payload).substring(3); return payload; };
And a view with the following:
<body ng-app="RetailerApp" ng-controller="MainController"> <div ng-show="customerDiv"> <p>Customer: {{customerId}}</p> </div> </body
When scanning an nfc card the alert fires, but the div fails to show. Is there something getting in the way of the ng-show directive?
Not a problem about this repo / project, check stackoverflow ;)
Having set up a basic cordova angular app and importing the ngCordova-nfc module, the following controller:
And a view with the following:
When scanning an nfc card the alert fires, but the div fails to show. Is there something getting in the way of the ng-show directive?