javascript - Switch View with Tabs in Polymer 1.0 -


i want change view in polymer when click on tab. thought of using paper-tabs , iron-pages described in paper-tabs documentation.

this html have realize this:

<html>    <head>    <title>test</title>    <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>    <link rel="import" href="bower_components/polymer/polymer.html">    <link rel="import" href="bower_components/paper-tabs/paper-tabs.html">    <link rel="import" href="bower_components/iron-pages/iron-pages.html">  </head>    <body>      <paper-tabs selected="{{selected}}">      <paper-tab>tab 1</paper-tab>      <paper-tab>tab 2</paper-tab>      <paper-tab>tab 3</paper-tab>    </paper-tabs>      {{selected}}      <iron-pages selected="{{selected}}">      <div>page 1</div>      <div>page 2</div>      <div>page 3</div>    </iron-pages>      </body>  </html>

changing tabs seems work. looks selected variable not getting set correctly because iron-pages element not change view. how can achieve needed data-binding in polymer 1.0? need create custom container element around 2 elements give them scope both access such variable?

you'll have embed elements in template[is="dom-bind"] element if want make curly brackets work. so

<template is="dom-bind" id="scope">   <span>{{number}}</span> </template> ... <script>   window.addeventlistener('webcomponentsready', function() { //you have make sure custom elements loaded     var scope = document.queryselector("template#scope");     scope.number = 1; // display number 1   }); </script> 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -