You don't update the input, you update the model to which the input is bound. Given the input you have:
<div ng-controller="MyCtrl">
<input type='text' ng-model='input' ng-click="myFunction('some value')">
</div>
This is bound to the input
property on the model. As a simple example, that's a property on $scope
. So you set that property to whatever you like, and then in your function you update it. Something like this:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.input = 1;
$scope.myFunction = function(value) {
$scope.input = value;
}
}
So the controller sets an initial default for the input
value (which should probably have a better name) as 1
. Then when your ng-click
event invokes myFunction
it can pass it a new value. Observe.