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.
Query parameters are optional key-value pairs. They will appear to the right of ? in a URL.
In a new project, generate a new
application
controller:$ ember g controller application
The
application
controller will be generated in theapp/controllers
folder.Update the application controller with a new
queryParams
forstudent
:/ 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 thestudent
property in the controller. If either one changes, the other will change as well.If the
student
property was set to anything other than null, then thestudent
property will have a default value. This is important to remember because...