Angular 2 RC3"RouterOutletMap没有提供者!"错误 [英] Angular 2 RC3 "No provider for RouterOutletMap!" error
问题描述
我有一个刚升级为使用"2.0.0-rc.3"
的Angular 2应用.
I have an Angular 2 app that I have just upgraded to use "2.0.0-rc.3"
.
我正在使用"@angular/router": "3.0.0-alpha.7"
中的新路由器,
I am using the new router from "@angular/router": "3.0.0-alpha.7"
,
现在,当我尝试在浏览器中加载应用程序时,我看到以下异常...
Now when I try to load the app in the browser I see the following exception...
VM17108:77 ORIGINAL EXCEPTION: No provider for RouterOutletMap!
我的app.component.ts看起来像...
My app.component.ts looks like...
import {Component} from '@angular/core';
import { HTTP_PROVIDERS } from '@angular/http';
import 'rxjs/Rx'; // Load all features
import {ROUTER_DIRECTIVES, provideRouter, RouterConfig } from '@angular/router';
import { TilesService } from '../app/shared/services/tiles.service'
import { LocationService } from '../app/shared/services/location.service'
@Component({
selector: 'tc-app',
template: '<router-outlet></router-outlet>',
directives: [ROUTER_DIRECTIVES],
providers: [HTTP_PROVIDERS,
TilesService,
LocationService
]
})
export class AppComponent { pageTitle: string = 'TileCase'; }
我的app.routes.ts看起来像这样...
My app.routes.ts looks like this...
import { provideRouter, RouterConfig } from '@angular/router';
import { TilesComponent } from '../app/tiles/tiles.component';
import { ProfileComponent } from '../app/profile/profile.component';
export const routes: RouterConfig = [
{ path: '', component: TilesComponent }
, { path: 'profile/:id', component: ProfileComponent }
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
我的main.ts看起来像这样...
and my main.ts looks like this...
import {bootstrap} from '@angular/platform-browser-dynamic';
import {AppComponent} from './app.component';
import { APP_ROUTER_PROVIDERS } from './app.routes';
bootstrap(AppComponent, [
APP_ROUTER_PROVIDERS
])
.catch(err => console.error(err));
使用RC2时一切正常.我不知道该怎么做才能再次进行这项工作.有什么想法吗?
This used to all be fine when using RC2. I can't figure out what I need to do to make this work again. Any ideas?
推荐答案
我已经弄清楚了这一点.实际上,这是一个Webpack错误. Webpack设置不正确,因此无法正确构建js,从而导致错误. 谢谢大家的帮助.
I've figured this one out. It was actually a Webpack error. Webpack wasn't setup correctly and was therefore not building out the js correctly which was leading to the error. Thanks for your help everyone.
这篇关于Angular 2 RC3"RouterOutletMap没有提供者!"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!