Angularjs 按键上的角度射击功能

Angularjs 按键上的角度射击功能,angularjs,keypress,Angularjs,Keypress,我想在angular中的按键上触发一个事件。此时,我有一个输入文本框: <input type="text" class="form-control input-sm" name="forenames" ng-model-options="{ updateOn: 'blur' }" ng-model="record.Forenames" ng-keyup="getInitials($event)"> 但它不会开火。有人对angul

我想在angular中的按键上触发一个事件。此时,我有一个输入文本框:

  <input type="text" class="form-control input-sm"
      name="forenames"
      ng-model-options="{ updateOn: 'blur' }"
      ng-model="record.Forenames"
      ng-keyup="getInitials($event)">

但它不会开火。有人对angular有什么建议吗?

您可以使用ng change进行此操作

$scope.getInitials = function () {
                           if ($scope.record.Forenames != null) {
                               $scope.record.Initials = $filter('genInitials')($scope.record.Forenames.replace(/[^\w\s]|_/g, ""), false);
                           } else {
                               $scope.record.Initials = "";
                           }

                       };