0
我做了一個自定義指令,以防止輸入密鑰。它僅適用於「輸入」元素,但它不綁定在「textarea」上。 這裏是我的jsAngularJs自定義指令不綁定「textarea」
function inputFocus() {
return {
restrict: 'E',
require: '?ngModel',
link: function ($scope, elem, attrs) {
elem.bind('keydown', function (event) {
var code = event.keyCode || event.which;
if (code === 13) {
$scope.$apply(function() {
$scope.$eval(attrs.inputFocus);
});
event.preventDefault();
}
});
}
}
}
和:
<textarea class="form-control" name="UserName" maxlength="50" rows="2"
ng-model="UserName" tabindex="2" required>
</textarea>
顯示文本區域 –
– rikhan0706
where do您致電指令 –