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');     } }); 

see working jsfiddle here


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -