Using query parameters

Query parameters allow you to use the URL for the application state. In these recipes, we'll use query parameters in several different ways to show how it works.

How to do it...

Query parameters are optional key-value pairs. They will appear to the right of ? in a URL.

  1. In a new project, generate a new application controller:
    $ ember g controller application
    

    The application controller will be generated in the app/controllers folder.

  2. Update the application controller with a new queryParams for student:
    / app/controllers/application.js
    import Ember from 'ember';
    
    export default Ember.Controller.extend({
        queryParams: ['student'],
        student: null
    });

    This will set up the binding between the student query parameter in the URL and the ...

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.