I am using extra function to handle keyboard input. It seems that value gets passed successfully but when I try to assign like this model += char;
value it fails. Why?
$scope.keyboardBtn = function(char){
if($scope.focusedInput.name == 'inputFirstName'){
$scope.keyboardAction($scope.persons[$scope.focusedInput.row].firstName, char);
}
};
$scope.keyboardAction = function (model, char) {
if(char == 'SPACE'){char = ' '}
if(char == 'CLEAR'){
if(model.length > 0){
model = model.substr(0, model.length -1 ); // fails
}
}else{
model += char; // fails
}
};
<button type="button" ng-click="keyboardBtn('SPACE')">SPACE</button>
<button type="button" ng-click="keyboardBtn('Z')">Z</button>
<button type="button" ng-click="keyboardBtn('CLEAR')">CLEAR</button>