In Polymer-Starter-Kit, how do I observe the current selected view inside <my-view1>
, so that I can create an observer and only trigger it whenever the <my-view>
is selected/visible?
In the iron-pages element, include the attribute "selected-attribute" like this:
<iron-pages
selected="[[page]]"
attr-for-selected="name"
fallback-selection="view404"
selected-attribute="selected"
role="main">
and in each of the views, include a property named "selected". You can set an observer to this selected property. It will be true when the page is shown and false otherwise.