I want to bind/unbind the keypress when user clicks to the checkbox. I tried to code a bit but not work at all without error in javascript console.
HTML
<textarea name="message" ng-model="message" ui-keypress="btnEnter"></textarea>
<input type="checkbox" ng-click="bindKeyEnter($event)">
JS
function MyCtrl($scope) {
$scope.btnEnter = {};
$scope.bindKeyEnter = function(e) {
var checkbox = e.target;
$scope.btnEnter = checkbox.checked ? {enter: 'sendMessage()'} : {}
};
$scope.sendMessage = function() { console.log($scope.message); }
}
Your suggestion?