angularjs - How to bind 2 models to one input field in Angular? -
is there anyway can bind 2 model values 1 input field?
suppose have input field want value of 2 variables in scope like:
<input type="text" model="sn_number; id" >
you cannot, there workarounds.
1. use ngchange update other model
<input type="text" ng-model="sn_number" ng-change="id=sn_number"/>
2. watch model, , when in changes, update another
$scope.$watch('sn_number', function(v){ $scope.id = v; });
you need watch changes in id
if want keep them in sync.
Comments
Post a Comment