mardi 15 mars 2016

Typescript with Ember Views

I have the following Ember View in Vanilla JS:

    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')

    )};

I am attempting to implement said Ember View in Typescript however:

  1. Typescript classes export a function
  2. Ember Views expect an object
  3. contenteditable seems to run due to Embers conventions (somewhere in its lifecycle) and sets the computed property appropriately

How could the contenteditable function be converted to work with Typescript?

So far I have stubbed out the following class:

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; 
  }

}

Is this even possible?

Thanks

Aucun commentaire:

Enregistrer un commentaire