在 angularjs 我有以下内容:
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();
}
});
};
});
html是:
<input type="text" ng-model="searchText" class="form-control"
placeholder="Search"
ng-enter="search($event, searchText)">
所以基本上,一旦我完成输入要搜索的文本,当我按下回车键时,我的控制器上的搜索功能就会运行。
我将如何在 Aurelia 中做到这一点?
我仍在学习它的功能,所以任何帮助将不胜感激。