UXCODA
UXCODA

Reputation: 1226

Emberjs Textarea 2 way binding with data that needs to be a getter

I am using Emberjs Textarea which has 2 way binding with the @value attribute.

The data I am passing into the value is from an argument and therefore needs to be return from a getter before I can use it in the template.

My question is how do I use 2 way binding with a getter. I keep on getting error messages stating that Cannot set property inputText of #<InputComponent> which has only a getter

I have tried to use {{mut}} and tried to create a setter for the getter but nothing has worked.

The post requests actually work but I still get those annoying errors in the console.

// Component JS    
get inputText() {
  return this.args.text;
}

// Component Template

<Textarea @value={{this.inputText}} @focusOut={{this.postRequest}} />

Upvotes: 0

Views: 121

Answers (1)

UXCODA
UXCODA

Reputation: 1226

Looks like setting the args value directly in the template will work.

<Textarea @value={{@inputText}} @focusOut={{this.postRequest}} />

Upvotes: 1

Related Questions