JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<div ng-app="app" ng-controller="mainCtrl">
<textarea keyup="">{{current_element.value}}</textarea>
<textarea id="23423" keyup="">{{current_element.value}}</textarea>
<br>
<button ng-click="current(0)">first</button>
<button ng-click="current(1)">second</button>
</div>
JavaScript
angular.module('app', [])
.controller('mainCtrl', function($scope) {
$scope.elements = [{value: 'first'}, {value: 'second'}];
$scope.current_element = null;
$scope.current = function(idx) {
$scope.current_element = $scope.elements[idx];
console.log('current is', $scope.current_element.value);
}
$scope.elements[1].value = 'second modified';
})
.directive('keyup', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).bind('keyup', function(e) {
var val = $(this).val();
scope.$apply(function() {
scope.current_element.value = val;
console.log(scope.elements);
});
});
}
}
})