JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app='converterApp' ng-controller='converterCtrl'>
Meters
<input type="text" ng-model="input"><br>
Kilometers
<input type="text" value="{{ input | distance:'mTOkm'}}"><br>
</div>
JavaScript
'use strict';
angular.module('converterApp', [])
.controller('converterCtrl', function($scope) {
$scope.input = 7000;
})
.filter('distance', function () {
return function(input, type) {
switch(type) {
case 'mTOkm':
return input / 1000;
case 'mTOcm':
return input * 100;
default:
return input;
}
};
});