14 Mart 2013, PERŞEMBE
Basarak form AngularJS ile Girin gönder
Bu durumda, seçenek ben bu girişi bastığımda bir işlevi Girin arama yapmak için ne var?
// HTML view //
<form>
<input type="text" ng-model="name" <!-- Press ENTER and call myFunc --> />
<br />
<input type="text" ng-model="email" <!-- Press ENTER and call myFunc --> />
</form>
// Controller //
.controller('mycontroller', ['$scope',
function($scope) {
$scope.name = '';
$scope.email = '';
// Function to be called when pressing ENTER
$scope.myFunc = function() {
alert('Submitted');
};
}])
CEVAP
28 HAZİRAN 2013, Cuma
Eğer form olmadan işlevini çağırmak istiyorsanız ngEnter benim yönergeyi kullanabilirsiniz:
Javascript:
angular.module('yourModuleName').directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter, {'event': event});
});
event.preventDefault();
}
});
};
});
HTML:
<div ng-app="" ng-controller="MainCtrl">
<input type="text" ng-enter="doSomething()">
</div>
Diğerleri my twitter gist account benim üzerinde müthiş direktifleri sunuyorum.
Bunu Paylaş:
Düğme olayı Tıklatın basarak farklı gi...
Basarak bir formu gönder düğmesi olmad...
Angularjs form içinde bir düğmesi sayf...
Nasıl koşullu olarak AngularJS form gi...
Ajax bir şekilde raylar form 3 (jQuery...