input cursor position example

input cursor needs to stay in it's place - not be moved to the end. Happens because I'm updating ng-model

by enigmarm

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<div ng-app='myApp'>
    <div ng-controller="myCtrl">
    <input id="compute1" ng-model="compute1" ng-change="math()" />
    <input id="compute2" ng-model="compute2" ng-change="math()"/>
  </div>
</div>

JavaScript

var myApp = angular.module('myApp', []);

function myCtrl($scope) {
  $scope.compute1 = 0;
  $scope.compute2 = 10;

  $scope.math = function() {
    $scope.compute1 = parseInt($scope.compute1);
    $scope.compute2 = parseInt($scope.compute2);

    $scope.compute1 = parseInt($scope.compute1);
  };
};

myApp.directive('thousandsformatter', function ($filter) {

});