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 Angular Basics Angular Components Structural Directives

Lokesh Sanapalli
Lokesh Sanapalli
1,242 Points

How does showComments and isLiked working without any function

I don't understand in the click event of buttons he used isLiked = !isLiked and showComments = !showComments. I don't understand where does the functions lie for these to get called? how does this work?

Sana Khateeb
Sana Khateeb
3,979 Points

I'm waiting for an answer on this too. I'm using IntelliJ to code this and it even says isLiked and showComments are unresolved variables but the code still works.

2 Answers

Robin Pedersen
Robin Pedersen
3,889 Points

I am not sure, but I think when "isLiked" is defined it is automatically false. And then when you click the button it says make "isLiked" the opposite of what it is (!isLiked) so "isLiked" become true. The CSS will generate when the "isLiked" is true. So if you push the button again it makes "isLiked" the opposite again, which is false and the CSS will be removed.

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hey Ken Howard

Could you Lokesh would like some explainer on this? Could you write a few details on this?

Regards
Andrew