O'Reilly logo

Ember.js Cookbook by Erik Hanchett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. 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.

  2. 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')); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required