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 trialCalvin Secrest
24,815 PointsToggle the editing variable between false and true when the editing button is clicked.
Toggle the editing variable between false and true when the editing button is clicked. Bummer! You need to alter the value of the 'editing' variable within the ng-click attribute.
Im not sure how to complete this task, please help!
<!doctype html>
<html lang="en">
<head>
<title></title>
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
</head>
<body ng-app="todoListApp">
<h1 ng-click="helloConsole()">My TODOs!</h1>
<div class="list" ng-controller="mainCtrl">
<input type="checkbox" ng-model="todo.completed">
<label ng-hide="editing">{{todo.name}}</label>
<input ng-show="editing" class="editing-label" type="text" ng-model="todo.name">
<div class="actions">
<a href="" ng-click="">Edit</a>
<a href="" ng-click="helloConsole()">Save</a>
<a href="" class="delete">Delete</a>
</div>
</div>
<button id="editorBtn" type="button">Enable Editing</button>
<div id="editor">
</div>
<script src="vendor/angular.js"></script>
<script src="scripts/app.js"></script>
</body>
</html>
2 Answers
Becky Steele
16,229 PointsHi Calvin! You can toggle the editing
variable between false and true by doing the following:
<a href=""ng-click="editing = !editing">Edit</a>
Every time the click event is triggered, you're telling editing to NOT be in its current state. So, if you're not currently editing the to-do item, when you click Edit, you will not NOT be editing, which is editing. If you are editing, you will trigger the NOT editing state.
I realize this can be tricky, so I encourage you to play with that functionality in Workspaces. Hope that helps!
Calvin Secrest
24,815 PointsThanks Becky I realize the error that was made, perhaps I got it confused if editing is false then !false will be true, and if it is true the !true will be false. However I got the code working now.
Becky Steele
16,229 PointsGlad you got it worked out Calvin!