Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Confused about the class expressions

I am wondering if anyone can enlighten me to why the ng-class expression looks like this in the video:

ng-class="{'editing-item' : editing, 'edited' : todo.edited}"

AND NOT:

ng-class="{'editing-item' : editing, 'edited' : edited}"

I made of the mistake of using the above code the first time round and the edited property isn't created, so the CSS isn't applied. Is it because we are creating the edited property by putting the object before the property in 'todo.edited'?

What confuses me even more is that when I use the following code, the editing class isn't being applied to the 'todo' object:

ng-class="{'editing-item' : todo.editing, 'edited' : todo.edited}"

So, when changing an existing class do we not reference the object and when creating the property do we have to reference the object?