聚合物嵌套应用程序路由未正确映射

Polymer nested app routes are not mapping correctly

我正在尝试正确设置一些基本路线。我正在使用 Polymer 1.5.0,但在使用嵌套路由时遇到问题。

我正在使用 app-route 0.9.2

this post suggests一样,Polymer 在路由中使用了去中心化的方法。因此,我决定执行以下操作:

<app-route route="{{route}}"
       pattern="/:page"
       data="{{data}}"
       tail="{{tail}}">
</app-route>

  <iron-pages selected="{{data.page}}" attr-for-selected="title" fallback-selection="404">
      <pgarena-home-app title="" route="{{tail}}" ></pgarena-home-app>
      <pgarena-tournament-app title="tournament" route="{{tail}}"></pgarena-tournament-app>
      <pgarena-account-app title="account" route="{{tail}}"></pgarena-account-app>
      <div title="404">
          <h1>{{data.page}} could not be found!</h1>
      </div>
  </iron-pages> 

子页面:

pgarena-account-app

<iron-pages selected="{{data.action}}" attr-for-selected="title" fallback-selection="404">
            <pgarena-account-index-view title=""></pgarena-account-index-view>
            <pgarena-account-login-view title="login"></pgarena-account-login-view>
            <pgarena-account-register-view title="register"></pgarena-account-register-view>
            <div title="404">
                <h1>Not found :(</h1>
            </div>
        </iron-pages>

pgarena-tournament-app

<!-- Chooses the new tournament page. -->
      <app-route 
        route="{{route}}"
        pattern="/:action"
        data="{{data}}"
        tail="{{tail}}"
        >
        </app-route>

    <iron-pages selected="{{data.action}}" attr-for-selected="title" fallback-selection="404">
        <pgarena-tournament-index-view title=""></pgarena-tournament-index-view>    
        <!-- The list of all the tournaments -->    
        <pgarena-tournament-list-view title="list"></pgarena-tournament-list-view>
        <div title="404">
            <h1>Not Found!</h1>
        </div>
    </iron-pages>

一切似乎都很好,对吧?根据 URL 我在这里所做的是利用元素的延迟加载。

我在 Polycasts examples 中看到他们使用 "hidden" 方法。他们在其中 select 元素。问题是我们丢失了 "Lazy Loading Advantage"。

有什么问题吗?

天哪!我完全忘记了。 In Polycasts #46/47 Rob Dodson 强烈强调 在使用 iron-selector 时,我们应该通过 one-way binding 与 square方括号 [] 与大括号 {}

所以在一天结束时 应该是:

<iron-pages selected="[[data.action]]"

而不是:

<iron-pages selected="{{data.action}}"