javascript - cant make new routing in Polymer 1.0 starter-kit (via page.js and iron-page) -
i new polymer , start polymer 1.0 starter-kit
i understand structure of polymer app , used page.js making new rout this.
window.addeventlistener('webcomponentsready', function() { // use page.js routing. micro // client-side router inspired express router // more info: https://visionmedia.github.io/page.js/ page('/', function () { app.route = 'home'; }); page('/users', function () { app.route = 'artworks'; }); //my new routing def. <<<<<<<< page('/artworks', function () { app.route = 'artworks'; }); page('/users/:name', function (data) { app.route = 'user-info'; app.params = data.params; }); page('/contact', function () { app.route = 'contact'; }); // add #! before urls page({ hashbang: true }); });
as understood page.js sets app.route values , polymer iron-pages uses app.route select right section show selected="{{route}}"
code this:
<iron-pages attr-for-selected="data-route" selected="{{route}}"> <section data-route="home">home section</section> <section data-route="users">users section</section> <section data-route="artworks">artworks section</section> <section data-route="user-info">user-info section</section> <section data-route="contact">contact section</section> </iron-pages>
after problem!? when use localhost:8000/artworks
page.js wont change localhost:8000/#!/artworks
same every other routed address localhost:8000/users
or localhost:8000/contact
result web browser search file @ localhost:8000/artworks folder , finds nothing 404 err occur.
i can not understand now. did missed here? idea?
i don't know why seems polymer not reading routing file @ all! copy-pasted routing code in app.js
file , works normal now!
so app.js has routing codes @ end , attached page.js in head of index.html(the main file of polymer app)
i have no idea why, it's working now.
Comments
Post a Comment