切换到RC5:多个组件

时间:2016-08-25 12:53:09

标签: angular angular2-routing

我在尝试切换到最新的RC5时遇到错误,我无法弄清楚它的含义:

Error: Template parse errors:
More than one component: DeviceComponent,OtherComponent ("
    </div>
    <div class="col-sm-12 col-md-4 col-lg-4">
        [ERROR ->]<device *ngIf="authService.authenticated"></device>
    </div>

奇怪的是抱怨这个HTML。

platform.module.ts

import { HttpModule } from '@angular/http';
import { NgModule }       from '@angular/core';
import { BrowserModule  } from '@angular/platform-browser';
import { FormsModule  } from '@angular/forms';
import { PlatformComponent }   from './platform.component';
import {AuthService} from '../../services/auth.service';
import {CookieService} from 'angular2-cookie/core';
import { RouterModule } from '@angular/router';
import {IncrementIndexPipe} from '../../pipes/incrementIndex';
import { TruncatePipe} from '../../pipes/truncate';
import { routing,
         appRoutingProviders } from './platform.component';

@NgModule({
    declarations: [TruncatePipe, IncrementIndexPipe],
    imports:      [BrowserModule,
                   HttpModule,
                   RouterModule,
                   FormsModule,
                   routing],
    bootstrap:    [PlatformComponent],
    providers:    [AuthService, CookieService, appRoutingProviders]
})
export class PlatformModule {}

我也一直在:

platform-browser.umd.js:937 ORIGINAL EXCEPTION: No provider for Router!

1 个答案:

答案 0 :(得分:0)

要解决:

platform-browser.umd.js:937 ORIGINAL EXCEPTION: No provider for Router!

我删除了所有旧的@ angular2 / router-deprecated

解决&#34;多个组件&#34;错误,如@rashfmnb建议,(1)删除所有双@Component装饰器(不在我的情况下)和(2)删除重复&#34;选择器&#34; @Component装饰器中的标签。这是问题出现在以前的angular2版本中。