Search code examples
htmlamp-html

Specify valid default value for [disabled] property on AMP page amp-bind


When using amp-bind, I'm receiving the following error:

Default value for <input [disabled]="ampState.success"> does not match
first result (). We recommend writing expressions with matching
default  values, but this can be safely ignored if intentional.

My initial states are:

  <amp-state id="ampState">
    <script type="application/json">
      {
        // ...
        "success": "",
      }
    </script>
  </amp-state>

And the offending element is:

<input type="submit" <!-- .... --> [disabled]="ampState.success" />

Is there anyway to remove this warning, consdering I can't provide a default value for [disabled] without it actually disabling the input?


Solution

  • I found this warning can be avoided by setting the state as follows:

      <amp-state id="ampState">
        <script type="application/json">
          {
            // ...
            "success": "",
          }
        </script>
      </amp-state>
    

    As the AMP validator looks for actualValue === expectedValue where the disabled properties initial actualValue is actually false, not ''