User-triggered updates with <amp-list> and <amp-bind>

With amp-bind, we can trigger amp-list to update, without a page reload, based on a user action such as tapping a button or entering some text. To do this, we must bind to the URL of amp-list with the square bracket syntax, like this: [src].

This amp-bind/amp-list combination is powerful pattern that we'll see several times in this chapter, so it's worth getting to know it well!

When the user clicks the remove link next to an item in the cart, then we'll add the product_id to the amp-list URL. When the URL changes, amp-list will automatically fetch the content at the new URL and render it.

Let's think about this in terms of state, expressions, and data bindings:

  • State: We'll add a property ...

Get AMP: Building Accelerated Mobile Pages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.