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.

example here


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -