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 AngularJS Basics (1.x) Using Angular's Built In Directives Using ng-click to change the application state.

Angular Basics

<!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="">Edit</a> <a href="" ng-click="helloConsole()">Save</a> <a href="" class="delete">Delete</a> </div> </div>

<script src="vendor/angular.js"></script> <script src="scripts/app.js"></script> </body> </html>

index.html
<!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="">Edit</a>
      <a href="" ng-click="helloConsole()">Save</a>
      <a href="" class="delete">Delete</a>
    </div>
   </div>

  <script src="vendor/angular.js"></script>
  <script src="scripts/app.js"></script>
</body>
</html>

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Trevino,

Co what is it you're struggling with in particular?

The challenge is split to 2 tasks. You need to add an angular directive to the HTML where you have your Edit button.

Secondly you need to Toggle the editing variable between false and true when the editing button is clicked. inside the click directive.

By the way i see that you added the challenge code to the post automatically but here's a great post that goes into how to add code to your posts yourself using markdown. :) Toggle the editing variable between false and true when the editing button is clicked.