Adding View Parameters
We’ve added the first route to our app, but there’s something not quite right about it. This route is specific to a single problem—problem #1. We don’t really want to make a new route for each problem we add to our app. We’d like to have one route (and one view) that can show any of the problems we have in our app.
To make this work, we’re going to parameterize our views. We’ll split the hash into two parts: a name and a parameter, using the dash in between as a delimiter. We’ll pass the parameter to the view function when we invoke it, and the function can use that data to construct the view. We’re going to call these values view parameters, and they will be our application’s first way to add data to the views.
In this ...
Get Serverless Single Page Apps 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.