Angular routing error: must include this file only once

I am playing with the Tour of Heroes tutorial found here . Everything works and looks good. However, after adding routing from the root page to the dashboard and detailing the hero, I got the following error in the console:

Unexpected condition on http://localhost:3000/dashboard: should only include this file once

      

The error is displayed after I clicked on the link to My Account. The message is output from this line of code:

expect(!loadTimeData, 'should only include this file once');

      

in VM1812: 155. JS version is V8 5.6.326.50. Angular version I am using 4.0.0 as stated in package.json :

"dependencies": {
  "@angular/common": "~4.0.0",
  "@angular/compiler": "~4.0.0",
  "@angular/core": "~4.0.0",
  ...
}

      

dashboard.component.ts

import { Component, OnInit  } from '@angular/core';

import { Hero } from '../heroes/hero';
import { HeroService } from '../model/hero.service';

@Component ({
  selector: 'my-dashboard',
  templateUrl: './html/dashboard.component.html',
  styleUrls: ['./css/app.css'],
})

export class DashboardComponent implements OnInit {

  heroes: Hero[] = [];

  constructor(private heroService: HeroService) { }

  ngOnInit(): void {
    this.heroService.getHeroes()
      .then(heroes => this.heroes = heroes.slice(1, 5));
  }
}

      

The page /dashboard

is associated with the app.component template , for example:

<nav>
  <a routerLink="/heroes">Heroes</a><!--another page, also problematic-->
  <a routerLink="/dashboard">Dashboard</a>
</nav>
<router-outlet></router-outlet>

      

and the route definition is defined in the module:

@NgModule({
  imports: [ RouterModule.forRoot(
    [
      { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
      { path: 'dashboard',  component: DashboardComponent },
    ]
  ) ],
  //...
})

      

Does anyone know what this error means and why is it showing up?

+3


source to share


1 answer


I have checked in every browser and it seems to only apply to Yandex browser. From my point of view, this error should be sent to Yandex support. However, this does not affect the end user experience or functionality. We can safely ignore it for the moment.



PS app - angular doesn't work on old safari (5.1.7), use latest version (9-10) only available on macOS or any other modern browser.

+6


source







All Articles