mercredi 12 avril 2017

Setup and Initialize Route in Glimmer js

Not long ago I hear about glimmer and decide to try it out.

Now I already try to do their tutorial and see the todo-mvc that glimmer already create but it seems that they use navigo to navigate through page.

I want to know if there's any proper way to setup route since previously I use ember.js and to setup route I just need to add another route at router.js.

Because of using navigo now I use code like this to navigate through routes

component.ts

import Component, { tracked } from '@glimmer/component';
import Navigo from 'navigo';

const router = new Navigo(null, true);

export default class MainPage extends Component {
    @tracked routeName;

    constructor(options){
        super(options);

        router
        .on({
            '/': () => { this.routeName = 'home'; },
            '/posts': () => { this.routeName = 'postList'; }
        })
        .resolve();
    }
};

template.hbs

<div>
    <a href="#/posts"><button>See All Posts</button></a>

    
        <post-list />
    
    
        <h1>PAGE NOT FOUND</h1>
    
</div>

Above code is working but it need me to have # after the domain. I think need to find another way or maybe more proper way than this one.




Aucun commentaire:

Enregistrer un commentaire