Storing application properties
One advantage of a controller is storing properties. Controllers have properties that are stored in the application, which is unlike the model where properties are saved to the server. In this recipe, we'll take a look at a few different types of properties and how they can be displayed in a template.
How to do it...
- In a new application, run the following command:
$ ember g controller application
In this application, we'll be using the
application controller
to store all our properties. - Update the application controller to add a new action and a few properties:
// app/controllers/application.js import Ember from 'ember'; export default Ember.Controller.extend({ prop2: 'test', prop3: true, actions: { enter(val){ alert(this.get('prop1')); ...
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.