Javascript 将指令转换为typescript中的组件

Javascript 将指令转换为typescript中的组件,javascript,angularjs,typescript,angular-components,Javascript,Angularjs,Typescript,Angular Components,我正在尝试将此指令转换为typescript中的组件。我看了一些视频和文章,介绍了如何做到这一点,但大部分都是javascript,所以有点不清楚 代码如下: export class TableRowBSGroupDirective implements ng.IDirective { restrict: string = 'A'; scope: any = { dirvm: '=', grouplvl: '=', class

我正在尝试将此指令转换为typescript中的组件。我看了一些视频和文章,介绍了如何做到这一点,但大部分都是javascript,所以有点不清楚

代码如下:

  export class TableRowBSGroupDirective implements ng.IDirective {
    restrict: string = 'A';
    scope: any = {
        dirvm: '=',
        grouplvl: '=',
        classlvl: '@'
    };

    templateUrl: any = balanceSheetFSPolicy.dirvmConstant.TableRowGroupTmpl;

    controller: any = ($scope: any) => {
        balanceSheetFSPolicy.balanceSheetFSViewModel = $scope.dirvm;
        $scope.balanceSheetFSPolicy = balanceSheetFSPolicy;
    };

    static factory(): ng.IDirectiveFactory {
        const directive = function () {
            return new TableRowBSGroupDirective();
        };
        return directive;
    }
}

angular
    .module('app.recon.statements')
    .directive('tableRowBsGroup', TableRowBSGroupDirective.factory());

有太多的
any
,不需要
选项
变量。但除此之外,是的,就是这样做的。谢谢!我不必以任何方式使用IComponentOptions吗?有太多的
any
,并且不需要
选项
变量。但除此之外,是的,就是这样做的。谢谢!我不必以任何方式使用IComponentOptions吗?
export class TableRowBSGroupCtrl {

    // Dependency Injection
    static $inject: [string] = [
        '$scope'
        // Apply all the dependancies for the component here 
        // $scope as an example
    ];

    // Access Bindings
    protected dirvm: any;
    protected grouplvl: any;
    protected classlvl: any;

    constructor(private $scope: ng.IScope) {
       // Place the Logics here which are in the controller function in your directive

    }

    public static factory() {
       // Here goes your static function body
    }

}

const options = {
  templateUrl: //the path for the template,
  bindings: {
    dirvm: '=',
    grouplvl: '=',
    classlvl: '@'
  },
  controller: TableRowBSGroupCtrl
};

export default (ngModule: any) => {
  ngModule.component('TableRowBSGroupCmp', options);
};