Stellen Sie die Caret-Position in Input mit AngularJS ein
Ich muss die Caret-Position einer Eingabe ändern, bei der eine bestimmte Anzahl von Ziffern hinzugefügt wird (Beispiel).
app.controller('MainCtrl', function($scope, $element, $timeout, $filter) {
//$scope.val = '12';
$scope.$watch('val', function(newValue, oldValue) {
if (!isNaN(newValue)) {
if (newValue.length > 3) {
//Set Caret Position
}
}
});
});
Ist es möglich, so etwas zu tunBeispiel?
Ich brauche zum Beispiel:
Eingabe: 1234.
Die Caret Position ist also 2.
Neue Ziffer: 9
Endspiel: 12934
Danke im Voraus.