打字稿与Ember访问量
问题描述:
我有以下的灰烬查看香草JS:打字稿与Ember访问量
App.TextboxView = Ember.View.extend({
tagName: 'div',
classNames: ['custom-text-area__child custom-text-area--text'],
attributeBindings: ['contenteditable'],
isEditable: true,
typing: false,
didInsertElement: function() {
},
contenteditable: (function() {
return this.get('isEditable') ? 'true' : 'false';
}).property('isEditable')
)};
我试图实施所述余烬观打字稿但是:
- 打字稿类导出的函数
- Ember Views expect a object
- contenteditable由于Embers约定(在其生命周期某处)似乎运行,并设置适当的计算属性
如何才能将函数转换为使用Typescript?
到目前为止,我已经灭掉了以下类:
export class TextboxView {
public tagName = 'div';
public classNames = ['custom-text-area__child custom-text-area--text'];
public atttributeBindings = ['contenteditable'];
public isEditable = true;
public typing = false;
constructor() {
var self = this;
}
}
这甚至可能吗?
答
好像我创建回答我自己的问题的习惯....
下实现按预期工作(我绝对试过,但显然是太快假定它没有工作LOL):
export class customTextBox {
public tagName = 'div';
public classNames = ['custom-text-area__child custom-text-area--text'];
public attributeBindings = ['contenteditable'];
public isEditable = true;
public typing = false;
public contenteditable = (function() {
return this.get('isEditable') ? 'true' : 'false';
}).property('isEditable')
public keyUp = function(event) {
}
public keyDown = function(event) {
}
}