typescript string in object property

Solutions on MaxInterview for typescript string in object property by the best coders in the world

showing results for - "typescript string in object property"
Noely
17 Jan 2016
1protected get ButtonClass(): object {
2    const buttonClass = {
3      'cursor-pointer hover:shadow focus:shadow': this.Enabled,
4      'opacity-40 cursor-not-allowed': !this.Enabled,
5      'whitespace-no-wrap': !this.LineBreaks
6    }
7    // The below allows you to define object properties based on a variable.
8    // If you were to assign them in the snippet above, it would cause an error.
9    buttonClass[`hover:${this.Color.FocusColorClass}`] = this.Enabled;
10    buttonClass[`focus:${this.Color.FocusColorClass}`] = this.Enabled;
11    buttonClass[`active:${this.Color.ActiveColorClass}`] = this.Enabled;
12    return buttonClass;
13  }