JSFiddle - React, Tailwind, and code Playground
by robertjd
HTML
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js"></script>
<body ng-app="omgplz">
<form ng-controller="FormController">
<input type="password" placeholder="without directive"/>
<input type="password" placeholder="with the directive" form-control=""/>
<p>something? {{something}}</p>
</form>
<input type="password" oninput="console.log(this.value)"/>
</body>
JavaScript
'use strict';
angular.module('omgplz',[])
.controller('FormController',function($scope){
$scope.something='';
})
.directive('formControl', function () {
return {
restrict: 'A',
link: function postLink(scope, element, attrs) {
element.on('input',function(){
scope.$apply(function(scope){
scope.something = element.val();
});
});
}
};
});