Search code examples
google-ampamp-bind

amp-bind Error: Default value for [variable] does not match first expression result


I am using amp-bind to bind the class attribute:

<div [class]="menu.menuClass" class=hide">...</div>

with the following amp-state element:

<amp-state id="menu">
  <script type="application/json">
  {"menuClass":"hide"}
  </script>
</amp-state>

However, after the page loads, I get the error:

amp-bind: Default value for [class] does not match first expression result (hide). This can result in unexpected behavior after the next state change.&#8203;&#8203;&#8203;

(this error is empedded in the div itself)

As you can see, my default value does match the first expression. What am I doing wrong?


Solution

  • Ah, this is a bug! :) I've filed this issue and we're working on a fix.

    We try to keep an eye on StackOverflow but feel free to file an issue in our GitHub project or ask a question on our Slack channel next time. Thanks for raising this, Gil.