【发布时间】:2016-12-22 15:30:11
【问题描述】:
我有下一个问题:Cannot read property 'outlets' of null。我的项目有效,但一段时间后它停止工作,但我没有更改我的代码。请帮助我。
更新
我的带有路由器插座的组件:
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '
<nav-menu></nav-menu>
<router-outlet></router-outlet>
<footer-component></footer-component>
',
})
export class AppComponent {}
app.module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { LocationStrategy, PathLocationStrategy, APP_BASE_HREF } from '@angular/common';
import { HttpModule } from '@angular/http';
import {FormsModule,ReactiveFormsModule} from '@angular/forms';
//+components
@NgModule({
imports:
[
BrowserModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
RouterModule.forRoot([
{ path: '', component: HomeComponent },
{ path: 'home', component: HomeComponent },
{ path: 'blog', component: BlogComponent },
{ path: '2016/:link', component: BlogArticleFullComponent },
{
path: 'admin', component: AdminComponent,
children: [
{ path: 'new', component: NewArticleComponent },
{ path: 'new-writer', component: NewWriterComponent },
{ path: 'new-tag', component: NewTagComponent }
] },
{ path: '**', redirectTo: '', pathMatch: 'full'}
])
],
declarations:
[//components
],
bootstrap:
[
AppComponent
],
providers:
[
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: LocationStrategy, useClass: PathLocationStrategy }
]
})
export class AppModule { }
附:有 ' 引用 ` 因为 stackoverflow ``-is 代码。
【问题讨论】:
-
欢迎来到 StackOverflow。任何人都无法通过这些信息来诊断问题。
-
向我们展示一些代码...您调用
outlets的部分 -
你想看哪个代码?错误发生在 1) core.umd.js:2838 2) core.umd.js:2843 3) core.umd.js:2844 4) Subscriber.ts:241
-
我从来没有写过
outlets自己 -
你很可能在某个地方有一个与该问题相关的
...向我们展示一些带有 app.module 的路由器调用,可能是从某个地方开始