Aurelia 1.0 routing configureRouter was never called

I tried to follow some aurelia.io routing tutorials like this http://www.tutorialspoint.com/aurelia/index.htm

I applied the configureRouter method in my App class, but it was never called

app.js

export class App {


        constructor()
        {
          console.log("app");
        }

        configureRouter(config, router){


          console.log("configureRouter");

          config.title = 'Aurelia';

          config.map([
              { route: ['','home'],  name: 'home',  
                moduleId: './components/home/home',  nav: true, title:'Home' },
              { route: 'about',  name: 'about',
                moduleId: './components/about/about',    nav: true, title:'About' }
          ]);

          this.router = router;
        }
    }

app.html

    <template>

      <nav>
          <ul>
            <li repeat.for = "row of router.navigation">
                <a href.bind = "row.href">${row.title}</a>
            </li>
          </ul>
      </nav>

    <router-view></router-view>
    </template>

As far as I understand, the configureRouter method in app.js should be called automatically when a router view is detected in the template, but it is not (and I am not getting any errors in the chrome console)

Any ideas?

+4
source share
2 answers

Did not read the tutorial, but it seems to work on my machine, maybe something is not correctly configured in your index.html?

. ( ): https://gist.run/?id=49f3aa8ac6cb72f2efc22c3073bc42d8

?

Btw. Aurelia, https://github.com/aurelia/skeleton-navigation

+4

, , <router-view></router-view>, configureRouter . , , , ,

: https://www.niclassahlin.com/2016/03/13/aurelia-router-configuration-caveat/

+6

Source: https://habr.com/ru/post/1653443/


All Articles