platform-b​​rowser.umd.js:937 ORIGINAL EXCEPTION:没有路由器的提供者,zone.js:344 app / template / app.template.html中的错误:4:4

时间:2016-09-14 12:07:21

标签: angular angular2-routing

//app.routing.ts

import { Router, RouterModule } from '@angular/router';

import { BrowserComponent } from './components/browser.component'; 
import { HomeComponent } from './components/home.component'; 
import { NotFoundComponent } from './not-found.component';


export const routing = RouterModule.forRoot([
    { path:'',component: HomeComponent },
    { path:'**',component: NotFoundComponent },
])

//app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { AppComponent }  from './app.component';
import { routing } from './app.routing';

import { GlobalService } from './services/global.service';

@NgModule({
  imports:      [ BrowserModule, FormsModule, routing, HttpModule ],
  declarations: [ AppComponent ],
  providers: [ GlobalService ],
  bootstrap:    [ AppComponent ]
})

export class AppModule { }

//app.component.ts

import { Component, Injectable, Input } from '@angular/core';  
import { Http, Response } from '@angular/http';   
import { Observable } from 'rxjs/Rx';     
import { Router } from '@angular/router';  

import { GlobalService } from './services/global.service';

@Component({     
    selector: 'cwf', 
    templateUrl: 'app/template/app.template.html'
})   

export class AppComponent {}

//main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule)

这里有什么问题..在模板中它只有" router-outlet"。还有什么我需要添加来摆脱这个问题。 index.html文件有指令" cwf"在app组件中定义的。请建议我。

0 个答案:

没有答案