Working with conditionals in templates
Using conditionals is fundamental to using Ember's templating engine. In the following recipes, we'll take a look at conditionals and how they work with templates.
How to do it...
Let's take a look at a simple example that displays text if some property is true.
- Create a new project and generate a new controller called
conditional
. Run this command in the root of theapplication
folder to createcontroller
andtemplate
:$ ember g controller conditional $ ember g template conditional
This will create the conditional controller.
- Update the
router.js
file with the newconditional
route:// app/router.js … Router.map(function() { this.route('conditional'); });
This will add a new
conditional
route. To access this route ...
Get Ember.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.