O'Reilly logo

Serverless Single Page Apps by Ben Rady

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

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

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