0
所以我使用TypeScript與Angular 1.5和Angular 1.5類型定義,但我無法弄清楚如何定義Angular組件內的綁定。TypeScript索引簽名對象的格式?
定義文件包含以下組件綁定
interface IComponentOptions {
...
bindings?: {[binding: string]: string};
...
}
但我怎麼萊特實際Javascript對象?上述
.component('myComponent', {
templateUrl: 'template.html',
controller: MyController,
controllerAs: 'vm',
bindings: {
one: '<',
two: '<'
}
});
的給我
Type '{ one: string; two: string; }' is not assignable to type '{ [binding: string]: string; }'.
所有答覆都讚賞!
怎麼樣 「一」: 「<」? –
你使用什麼版本的打字稿? –