如何自动绑定放大器状态从远程源?

问题描述

我的amp页面的状态如下:

<amp-state id="remoteData" src="https://remoteDataurl.com">
  <script type="application/json">
    {
      "name": "Foo","email": "foo@bar.com"
    }
  </script>
</amp-state>

我想将响应绑定到页面中的元素:

  <p [text]="'Hello ' + remoteData.name"> ... </p>
  <p [text]="'Your email is ' + remoteData.email"> ... </p>

文本实际上已经被绑定,但是直到页面上发生事件时它才会刷新。

如何获取它以自动刷新状态?

解决方法

我相信<amp-state>不会为您提供此功能。

我目前的解决方案是将<amp-list>与以下属性一起使用。

<amp-list 
  layout="fixed-height"
  height="80"
  src="https://remoteDataurl.com"
  single-item 
  items="."
>
  
  <template type="amp-mustache">
    <p> Hello {{ name }} </p>
    <p> Your email is {{ email }} </p>
  </template>

</amp-list>