camilajenny
camilajenny

Reputation: 5034

Angular routing error: should only include this file once

I am playing with tutorial Tour of Heroes found here. Everything runs and looks fine. However, after I added routing from root page to dashboard and to hero's detail, I got the following error in the console:

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

The error is seen after I click in the link to Dashboard. The message is thrown from that line of code:

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

in VM1812:155. JS version is V8 5.6.326.50. Version of Angular I am using is 4.0.0, as declared 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 /dashboard page is linked in app.component template, like that:

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

and route definition is defined in a module like that:

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

Anyone knows what this error means and why it pops up?

Upvotes: 3

Views: 1154

Answers (1)

Sergey Zykov
Sergey Zykov

Reputation: 697

I checked with every browser and seems it applies only to Yandex browser. From my perspective, that bug needs to be sent to Yandex Support team. However, it doesn't affect end-user experience or any functionally. We can safely ignore it for now.

PS - angular application isn't working on old safari (5.1.7), use the latest one(9-10) which is available only on MacOS or any other modern browser.

Upvotes: 6

Related Questions