I have the following input
<input id="mainOdd1Id" type="number" ng-model="data.mainOdd1" min="0" step="any" ng-attr-placeholder="{{data.mainOdd1}}" ng-focus="focus($event)" ng-blur="blur($event)">
And the following function which execute on blur
$scope.blur = function($event){
var id = $event.target.getAttribute('id');
switch(id) {
case "mainOdd1Id":
$scope.data.mainOdd1 = func($scope.data.mainOdd1);
break;
case "mainOdd2Id":
$scope.data.mainOdd2 = func($scope.data.mainOdd2);
break;
case "bkOdd1Id":
$scope.data.bkOdd1 = func($scope.data.bkOdd1);
break;
case "bkOdd2Id":
$scope.data.bkOdd2 = func($scope.data.bkOdd2);
break;
default:
break;
}
}
I would like to avoid the switch command by getting a "pointer" to the data field by the id and changing it. (*pointer = function(*pointer))
Is that possible?
Thanks