Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember Uncaught TypeError: Cannot read property 'yield' of undefined

We are getting an error Uncaught TypeError: Cannot read property 'yield' of undefined for the following hbs code;

<button {{if isButtonEnabled 'enabled' 'disabled'}}>Test</button>

isButtonEnabled is a property defined on my corresponding controller

like image 760
copenndthagen Avatar asked Feb 11 '16 09:02

copenndthagen


People also ask

What is cannot read property of undefined in JavaScript?

The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is read or a function is called on an undefined variable. TypeError: Cannot read properties of undefined (reading x) Undefined means that a variable has been declared but has not been assigned a value.

Why can’t I call a function on an undefined variable?

In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

What is the meaning of undefined in JavaScript?

Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.


1 Answers

You'll have to flip your condition and do this. I just had this exact problem and this was the solution.

<button disabled={{isButtonDisabled}}>Test<button>
like image 151
dharga Avatar answered Oct 07 '22 21:10

dharga