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 trialChristopher Lebbano
15,338 PointsHow does the service delete todo method actually remove the element from the HTML?
In this video ( https://teamtreehouse.com/library/using-services-to-save-and-delete-data ) he creates a new method in the service and passes it into the controller. I understand how this works, but what I don't understand is how exactly the HTML element is removed from the web page when he clicks delete.
What I do understand is how the method is attached to the service then passed to the controller.
I do understand how he grabs the index from the todo array and how he uses the index in the function to splice (remove) the todo from the array.
What I don't get is how the HTML is updated just because a variable is deleted. I would think that you would also have to include some event listener to see when a "change" is made or something and then update the live html in the browser.
1 Answer
Ernesto Salazar
21,555 PointsI don't know exactly how Angular works under the hood, but he is the responsable for making those changes in the UI, so you don't need to worry about watch any changes in your data to then manipulate the UI.