Reputation: 1181
I have this code in my system.config.js when it comes to importing angular2's old router (the deprecated one).
'@angular/router-deprecated': 'npmcdn:@angular/router-deprecated@'+angularVersion,
I'm getting this error:
system.src.js:43 Uncaught (in promise) Error: ROUTER_PROVIDERS is not defined(…)
This is the plunkr here
How can I fix this?
Upvotes: 0
Views: 3802
Reputation: 135802
Your plunker has several problems.
app/index.ts
:Add the imports:
import { ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HashLocationStrategy, LocationStrategy } from '@angular/common';
import { provide } from '@angular/core';
Not mandatory, but you should remove the .ts
extension:
import { App } from './app2.ts';
Should really be:
import { App } from './app2';
app/home.ts
Add the path to the templateUrl
:
templateUrl: './home.html'
Becomes:
templateUrl: './app/home.html'
app/add_developer.ts
Also add the path to the templateUrl
:
templateUrl: './add_developer.html'
Becomes:
templateUrl: './app/add_developer.html'
*ngFor
notationConsider updating the *ngFor
notation to the latest. You are using it in several places. Use let
instead of #
. For instance, at app/home.html
:
<tr *ngFor="#dev of getDevelopers()">
Should be
<tr *ngFor="let dev of getDevelopers()">
Click here for your updated plunker (including the *ngFor
changes).
Upvotes: 1
Reputation: 20037
Add below line in index.ts
import { ROUTER_PROVIDERS, RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated';
And add providers: [ROUTER_PROVIDERS]
in you app2.ts file.
Upvotes: 0