angular directive ngEnter
宣告
使用
angular.module('app').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.preventDefault();
}
});
};
});
使用
<input type="text" ng-model="keyword" ng-enter="surch()"/>
留言
張貼留言