Say I have a model in angular, with three variables in my model, say a,b,c, and I want to have c=a*b.
I've done it by adding a function, updateC(), that updates c, and then my HTML would look like this:
<input name="a" ng-model="a" ng-change="updateC()"></input>
<input name="b" ng-model="b" ng-change="updateC()"></input>
<input name="c" ng-model="c" readonly></input>
But that's not a nice solution if I have alot of such triplets, because I need to define a function for each such triplet. Is there a way to bind the value of the element in the model to some formula?
I.e. is there some attribute ng-like-bind-but-updates-model such that the following html will work:
<input name="a" ng-model="a"></input>
<input name="b" ng-model="b"></input>
<input name="c" ng-model="c" ng-like-bind-but-updates-model="a*b" readonly></input>
valueand the{{...}}binding instead ofng-model? I.e.<input name="c" value="{{ a*b }}" readonly />.<input name="c" ng-model="a * b" readonly></input>cwith the right value.