问题描述:

Sorry, english is my second language.

Here is my problem. I had bound two textboxes to the scope. Each textbox needs to affect the other on changes. You'll understand that it cause conflict. From now, I've got that :

<input type="text" ng-model="celcius" ng-change="farenheit=celcius * 9/5 + 32 || ''">

<input type="text" ng-model="farenheit" ng-change="celcius=(farenheit - 32) * 5/9 || ''">

But it doesn't work properly. Any idea how to trick that ?

网友答案:

You need to use type="number" instead of type="text" so the expression in the ng-change directive can calculate the values as numbers instead of text.

相关阅读:
Top