1
我想在用戶單擊複選框時綁定/解除綁定按鍵。我試圖編碼一點,但沒有在JavaScript控制檯中的錯誤沒有任何工作。Angular UI - 爲按鍵綁定和解除綁定
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); }
}
您的建議?