In my example I want to update model when user focus the textfield. In short append 'px' string to the existing value.
HTML:
<div ng-app>
<div ng-controller="PixelCtrl">
<div>
{{pixel}}
</div>
<input type="text" ng-focus="updatePX($event)" ng-model="pixel" />
</div>
</div>
JS:
function PixelCtrl($scope) {
$scope.pixel = "120";
$scope.updatePX = function(e){
debugger;
alert(e.target.value);
e.target.value = e.target.value + "px";
$scope.$apply();
}
}
As you all can see I have also used $scope.$apply. Most likely I am doing something wrong.
JSFIDDLE: https://jsfiddle.net/ashwyn/U3pVM/27621/
pxto the binding? For example,{{pixel}}px