Broadcast problem?


#1

Hello, i’m using this plugin https://github.com/ttatarinov/lineapro-phonegap-plugin
I initialized so:

LineaProCDV.initDT(lineaPro.onDeviceConnected, lineaPro.onSuccessScanPaymentCard, lineaPro.onBarcodeScanned, lineaPro.onCancelBarcode, lineaPro.onErrorBarcode);

and I set a service with broadcaster:

arsmag.service('lineaPro', function($state, $rootScope) {

	this.action = '';

	this.onDeviceConnected = function (data) {
		console.log("onDeviceConnected: " + data);
	}

	this.onSuccessScanPaymentCard = function (data) {
		console.log("onSuccessScanPaymentCard: " + data);
	}

	this.onBarcodeScanned = function (data) {
		console.log("--- "+ $state.current.name);
		console.log("onBarcodeScanned: " + data.rawCodesArr);

		$rootScope.$broadcast('onBarcodeScanned', {
                       data: data.rawCodesArr
                });
	}

	this.onCancelBarcode = function (data) {
		console.log("onCancelBarcode: " + data);
	}

	this.onErrorBarcode = function (data) {
		console.log("onErrorBarcode: " + data);
	}

});

but… when i try to popolate an html element, value isn’t displayed…
in the controller:

$scope.$on('onBarcodeScanned', function(event, data) {
	var barcode = String(data.data);
	console.log(lineaPro.action);
	console.log(barcode);
	sendAndLoad.CP	= barcode;
	$scope.cp	= sendAndLoad.CP;
});

the logs works fine, but in the view the value isn’t displayed.
It is known that if I press a button in the view, for a while the value appears.
some idea?