回购:https://github.com/leongaban/lifeleveler.io
我不知道为什么我收到此错误,我在我的app.component.ts中导入了路由器
我尝试使用app.component
来保留主<router-outlet>
,并首先提供登录视图。
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { routing } from './app.routing';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { AuthService } from './shared/services/auth.service';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/observable/throw';
@NgModule({
imports: [
BrowserModule,
FormsModule,
RouterModule,
routing
],
declarations: [
AppComponent,
LoginComponent
],
providers: [
AuthService,
],
bootstrap: [ AppComponent ]
})
export class AppModule {}
import { Component, OnInit } from '@angular/core';
import { User } from './shared/models/user';
import { Router } from '@angular/router';
@Component({
selector: 'my-app',
templateUrl: './app/app.component.html',
styleUrls: ['./app/app.component.css']
})
export class AppComponent implements OnInit {
ngOnInit() {
}
}
<router-outlet></router-outlet>
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
export const routes: Routes = [
{
path: '',
redirectTo: '/login',
pathMatch: 'full',
},
{
path: 'login',
component: LoginComponent
}
]
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
答案 0 :(得分:1)
看起来您可能多次导入RouterModule。
我会从您的app.routing.ts
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
在app.module
我将使用以下网址导入您的路线:
import { routes } from './app.routing';
然后将RouterModule
导入为:
RouterModule.forRoot(routes)
答案 1 :(得分:1)
答案 2 :(得分:0)
您应该在Model
:
RouterModule.forRoot(routes)
声明
AppModule
并将其从@NgModule({
imports: [
BrowserModule,
FormsModule,
RouterModule.forRoot(routes)
],
declarations: [
AppComponent,
LoginComponent
],
providers: [
AuthService,
],
bootstrap: [ AppComponent ]
})
export class AppModule {}
文件中删除:
app.routing.ts
答案 3 :(得分:0)
只需导入RouterOutlet
$montantTotal = 29.85
$result = -3.5527136788005E-15