【发布时间】:2023-03-28 06:01:02
【问题描述】:
我正在使用带有 Babel 和 Typescript 的 webpack
我有这个控制器:
// HelloWorldController.ts
class HelloWorldController implements ng.IComponentController {
constructor(private $scope: ng.IScope) {
}
public over(): void {
this.$scope.color = this.change();
}
}
和他的组件选项
export class HelloWorldComponent implements ng.IComponentOptions {
public bindings: {[binding: string]: string};
public controller: Function;
public templateUrl: string;
public constructor() {
this.bindings = {
color: '=',
change: "&"
};
this.controller = HelloWorldController;
this.templateUrl = "HelloWorld.html";
}
}
app.component('helloWorld', new HelloWorldComponent());
当我转译这段代码时,我得到了这个错误:
error TS2339: Property 'change' does not exist on type 'HelloWorldController'
如何使用 Typescript 访问控制器内的绑定引用?
【问题讨论】:
标签: angularjs typescript webpack babeljs