Javascript AngularJS:Property';Ncenter';不存在于类型';国际航空运输协会(IATFORITES)';

Javascript AngularJS:Property';Ncenter';不存在于类型';国际航空运输协会(IATFORITES)';,javascript,angularjs,typescript,angularjs-directive,webstorm,Javascript,Angularjs,Typescript,Angularjs Directive,Webstorm,我正在使用Typescript并将angular的定义从1.3迁移到,导致我的MainModule.ts中出现以下错误: Error:(14, 43) TS2339:Property 'ngEnter' does not exist on type 'IAttributes'. 触发编译器错误的代码正在定义angularjs模块: angular.module('myApp', ['ngRoute', 'ui.bootstrap', 'ui.bootstrap.modal', 'smart-t

我正在使用Typescript并将angular的定义从1.3迁移到,导致我的
MainModule.ts中出现以下错误:

Error:(14, 43) TS2339:Property 'ngEnter' does not exist on type 'IAttributes'.
触发编译器错误的代码正在定义angularjs模块:

angular.module('myApp', ['ngRoute', 'ui.bootstrap', 'ui.bootstrap.modal', 'smart-table'])
    .service('appService', AppService)
    .controller('MainCtrl', MainCtrl)
    .controller('uploadTSCtrl', UploadTSCtrl)
    .controller('inputCtrl', InputCtrl)
    .controller('reportCtrl', ReportCtrl)
    .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); // <<<<<<<<<<<<< here
                    });
                    event.preventDefault();
                }
            });
        };
    })
angular.module('myApp',['ngRoute','ui.bootstrap','ui.bootstrap.modal','smart table']))
.service('appService',appService)
.controller('MainCtrl',MainCtrl)
.controller('uploadTSCtrl',uploadTSCtrl)
.controller('inputCtrl',inputCtrl)
.controller('reportCtrl',reportCtrl)
.指令('ngEnter',函数(){
返回函数(范围、元素、属性){
元素绑定(“按键按下”,函数(事件){
if(event.which==13){
作用域:$apply(函数(){

scope.$eval(attrs.ngEnter);//我也遇到过这样的问题,只是做了一些修改

scope.$eval(attrs['ngEnter']);


为了避免这个问题。

为了完整起见,我还找到了另一种使用预构建指令的方法,该指令只需插入即可用于此操作:

scope.$eval((attrs as any).ngEnter);