amp-htmlamp-listamp-bind

amp-bind not working inside to change an element's class inside AMP Story


I have created a sidebar inside an AMP Story Page.

Inside the sidebar i have a menu with links and sub menus. I am trying to add an "active" class to submenu items when their parent is clicked using this code

<div class="caret" on="tap:AMP.setState({sidebar.openMenu: 1})">

And grabbing the toggle in the submenu item with

<ul [class]="sidebar.openMenu ? 'active' : ''" class="subMenu">

The problem is that when i tap the parent Menu item, a console error

AMP.setState is not whitelisted

appears and nothing changes.

How can i whitelist the AMP.setState action inside the AMP Story Page sidebar?


Solution

  • You don't need amp-bind to create a multi-level amp-sidebar navigation, use AMP actions and events instead.