Aurelia 1.0 routing configureRouter never called
NickName:Nico AD Ask DateTime:2016-09-02T22:01:31

Aurelia 1.0 routing configureRouter never called

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

I implemented a configureRouter method in my App class but it s 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 is supposed to be called automatically when router-view is detected in the template, but it s not the case (and I dont get any errors in chrome console)

Any ideas?

Copyright Notice:Content Author:「Nico AD」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39294287/aurelia-1-0-routing-configurerouter-never-called

Answers
deviprsd 2017-02-08T20:25:16

I had a similar problem but turns out that if there is no <router-view></router-view> in the template the configureRouter method is never called. Even though you found your solution but maybe other people might find relief in this solution also \n\nSource: https://www.niclassahlin.com/2016/03/13/aurelia-router-configuration-caveat/",


More about “Aurelia 1.0 routing configureRouter never called” related questions

Aurelia 1.0 routing configureRouter never called

I tried to follow some tutorials on aurelia.io routing like this one http://www.tutorialspoint.com/aurelia/index.htm I implemented a configureRouter method in my App class but it s never called a...

Show Detail

Aurelia compose element view model, configureRouter not being called

I have a parent view with routing (view): &lt;div class="render-body ${nav.hide === true?'hide':''}"&gt; &lt;router-view class="router-view flex"&gt;&lt;/router-view&gt;

Show Detail

configureRouter not called on compose view models

It seems configureRouter is not called when using compose binding. This is the View: &lt;template&gt; &lt;compose view="./ask-banner.html" view-model="./ask-banner"&gt;&lt;/compose&gt;&

Show Detail

trying to create aurelia routing in plunker

I am working on creating a page in plunker to demo aurelia routing. Here is the link. For some reason, I am unable to show the route in the page. I am able to run similar code in my local environment

Show Detail

How can Aurelia child routing work with a parameter?

I feel as though similar questions have already been asked, but I have been unable to find my answer. I'm trying to segregate my application by its features. Ideally each feature would be able to ...

Show Detail

Aurelia activate function never be called

I programmed a tool-bar using Aurelia + WebStorm. In this tool-bar there is an activate function but it never be called automatically. You can see the TypeScript code here: import {autoinject} from "

Show Detail

How to use Aurelia's router with server-side routing

I have an Aurelia project that uses server-side routing with MVC. I am using a layout file that points to a main "app" component, like this: &lt;div aurelia-app="main" start="app" data-model='@Json.

Show Detail

aurelia routing parameter validation

I am trying to figure how best to handle two types of bad routes. One is a type check. Since i know my ID should be a numeric value Two is when they have put in a bad order number For the type ...

Show Detail

Aurelia unit test route paths to modules

I've been looking for a good pattern to unit test routes I have configured in my application so that I know the specified modules exist on disk as defined. Here is an example route configuration:

Show Detail

Aurelia not loading URLs without hash

I have read the other questions on this issue and the answers didn't seem to help me. Maybe because I'm using ASP CORE. If I navigate to http://localhost:5000/#home the routing works fine. But when I

Show Detail