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 Ember.js Controllers Challenge: Controller Properties

Devin Scheu
Devin Scheu
66,191 Points

Java Help

Question: Add an action to the controller below called hidePuppies. When it is triggered, make it change the puppiesShowing property to false.

Code:

js/app.js
AnimalShelter = Ember.Application.create();

AnimalShelter.Router.map(function() {
  this.resource('puppies');
});

AnimalShelter.IndexRoute = Ember.Route.extend({
  renderTemplate: function() {
    this.render('puppies');
  }
});

AnimalShelter.PuppiesController = Ember.Controller.extend({
  puppiesShowing: true,
  actions: {
    // your code goes here
    puppiesShowing: false;
  }
});
index.html
<!DOCTYPE html>
<html>
<head>
  <title>Animal Shelter</title>
</head>
<body>
  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-v1.3.0.js"></script>
  <script src="js/libs/ember-1.8.1.js"></script>
  <script src="js/app.js"></script>

  <script type="text/x-handlebars" id="puppies">
    <div class='container'>
      <h1>Puppies</h1>
      <p>These puppies will love you and snuggle you until your heart melts.</p>
    </div>
  </script>

</body>
</html>

1 Answer

Alex Stophel
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Stophel
iOS Development Techdegree Student 11,552 Points

You'll want to create a method inside of 'actions' that sets the puppiesShowing property to false. Here's an example of how you might create a method within 'actions' and set a property:

actions: {
  actionName: function () {
    this.set('propertyName', value);
  }
}