October 2017
Intermediate to advanced
370 pages
8h 57m
English
Next, let's set up two amp-selectors to let the user choose color and style. First the color option:
<amp-selector class="style-chooser" on="select:AMP.setState({product:{color: event.targetOption}})"> <span option="red" selected></span> <span option="green"></span> <span option="blue"></span> <span option="yellow"></span></amp-selector>
We use AMP.setState() to change the color property of the state whenever a new selection is made and the select event is triggered.
The style selector is very similar. There is a difference, however. It's common for different options to have different prices. For example, a large size could be more expensive than a small. We'll implement a simple option-based ...
Read now
Unlock full access