O'Reilly logo

Rails, Angular, Postgres, and Bootstrap, 2nd Edition by David B. Copeland

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

Reusing Markup with a Generic Text Field Component

You’ve already seen how to reuse markup when we created the AddressComponent in Chapter 11, Asynchronously Load Data from Many Sources. Our TextFieldComponent is even more generic, so we will need to have a few more properties that the user has to set. To make this generic, we need to get a few bits of information from the user:

  • The name of the field being edited

  • A label to use for the field

  • An optional flag for the addon (you’ll recall from Form Add-Ons that we added nicely styled @ in front of the username control)

Let’s see how those values would be used in our markup. A completely generic version of our text field would now look like 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