1
我跟着這個例子Submit form on pressing Enter with AngularJSangular.js按鍵指示事件神祕不發射
但我不能讓它工作。這完全是莫名其妙的。爲什麼按鍵事件不會被我的指令困住?
http://plnkr.co/edit/A9oio2F61yHssE49aiCb?p=preview
app.directive('enterKey', function($log) {
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();
}
});
};
});
我真是個白癡。謝謝。 – metalaureate
@metalaureate沒有問題..很高興幫助你..謝謝:) –