angularjs - Angular UI - Bind and unbind for keypress -
i want bind/unbind keypress when user clicks checkbox. tried code bit not work @ 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?
you this:
html:
<div ng-controller="tstctrl"> <input ui-keypress="{enter: enter}" /> <input type="checkbox" ng-model="doonenter" /> </div>
javascript:
app.controller('tstctrl', function ($scope) { $scope.enter = function () { if ($scope.doonenter) realonenter(); }; function realonenter() { console.log('on enter'); } });
Comments
Post a Comment