1

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 just fine. I think it is something in plunker that has to be done differently.

Here is the code:

app.html

<template>
  <h1>Hello</h1>
  <div class="row col-lg-6 col-lg-offset-3">
    <div class="btn-group col-sm-offset-1" role="group" aria-label="...">
      <a repeat.for="row of router.navigation" class="${row.isActive ? 'active btn btn-primary' : 'btn btn-default'}" href.bind="row.href">
        ${row.title}
      </a>
    </div>
    <router-view></router-view>
  </div>
</template>

app.ts

import { Aurelia, PLATFORM } from "aurelia-framework";
import { Router, RouterConfiguration } from "aurelia-router";

export class App {
  router: Router;
  // Configure Routing
  configureRouter(config: RouterConfiguration, router: Router): void {
    console.log("Aurelia routing");
    config.title = "Aurelia Routing";
    // config.options.root = "/";
    config.map([
      {
        route: "",
        redirect: "home",
        settings: { icon: "home" }
      },
      {
        route: "home",
        moduleId: "./Home",
        nav: true,
        title: "Home",
        settings: { icon: "home" }
      },
      {
        route: "/support",
        moduleId: "./Support",
        nav: true,
        title: "Support Request",
        settings: { icon: "home" }
      }
    ]);
    this.router = router;
    console.log(router);
  }
  // console.log(this.router);
}

Further details, such as bootstrapping, etc can be found in plunker link.

Ray
  • 1,095
  • 3
  • 18
  • 43

1 Answers1

2

There's a typo/error in your main.ts:

aurelia.use.basicConfiguration()

Should be:

aurelia.use.standardConfiguration()

Changing this, I saw the console.log messages you put in the configuration, but I got another error, but the routing works now.

Jesse
  • 3,522
  • 6
  • 25
  • 40
  • Thanks Jesse. I will look in to the other issue, but I do see that it now executes routing configuration from `app.ts` file. – Ray May 03 '18 at 11:49