4
votes

To configure a route I need a ViewModel and optionally a View, but many times I see that ViewModel is required only to get a html. As result, I stay with many empty classes in js/ts files, just to make router config work.

The question: is there any way to remove this empty classes and configure routes like this:

config.map([
    { route: ['', '/'], moduleId: 'no-selection.html',  title: 'Select'},
    { route: 'about', moduleId: 'about.html', title:'About'},
    { route: 'contacts/:id',  moduleId: 'contact-detail',  name:'contacts'}  
]);
2
As far as I know there is no way to configure a route to a html-only-component yet. Wondered this myself, but half a year ago - kabaehr
I skipped somes steps and publish first on GitHub, but I don't receive a feedback yet. And I don't found any answer online. Then, I hope receive some info here. - Abraão Alves

2 Answers

4
votes

This isn't currently possible, but it is an enhancement we would like to do at some point in the future.

1
votes

You can create a generic parameterised route with a generic view-model. In the template you can then use "compose" to display the static html...

add a route to your config

{'views/:page', moduleId: 'views/index'}

in views/index:

export class IndexViewModel {

    private page;

    constructor() { }

    activate(params) {
        this.page = './' + params.page + '.html';
    }

}

in views/index.html

<template>
    <compose view="${page}"></compose>
</template>