【发布时间】:2016-12-28 16:40:55
【问题描述】:
我正在使用 Angular 1.5 的 Typescript。我在将变量传递给组件以绑定时遇到问题。
这里是相关代码——我已经去掉了大部分不相关的代码。
module xyz.dashboard {
class PatientPhaseCountController {
public static $inject = [];
public title: string;
public chartType: string;
///// /* @ngInject */
constructor() {
this.title = 'Patient Phase Count';
console.log(this.chartType);
this.$onInit();
}
public $onInit(): void {
console.log(this);
};
}
class PatientPhaseCount implements ng.IComponentOptions {
public bindings: any;
public controller: any;
public templateUrl: string;
constructor() {
this.bindings = {
chartType: '@'
};
this.controller = PatientPhaseCountController;
this.templateUrl = 'app/dashboard/patientPhaseCount/patientPhaseCount.component.html';
}
}
}
这是 html sn-p:
chartType 始终未定义。任何帮助表示赞赏。
【问题讨论】:
标签: angularjs angularjs-components