Beginning AngularJS

(WallPaper) #1
CHApTer 6 ■ WorkIng WITH ForMS

The select Element

The select element is a container for a series of option elements. These option elements display in the browser as a
drop-down list. Unless you use the multiple attribute, this control will allow the user to pick just one item from the
list of options. Take a look at Listing 6-2, which shows two select elements, one with the multiple attribute specified
and one without it specified.


Listing 6-2. Two Very Similar select elements, Two Very Different Outcomes






These are close to identical. The only difference is that the second select element uses the multiple attribute.
Figure 6-1 shows the rendered lists.


Figure 6-1. Lists with and without the multiple attribute


It is common to see the select element set up such that its first option is the user’s prompt. For example, the
select element in Listing 6-3 uses its first option to display “Choose your favorite food.”

Free download pdf