Bitte fügen Sie eine @ - Rohr/Direktive@/@Component-annotation. Fehler
Bin ich in einer situation stecken hier. Ich erhalte eine Fehlermeldung wie diese.
compiler.es5.js:1694 Uncaught Error: Unexpected value 'LoginComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
at syntaxError (compiler.es5.js:1694)
at compiler.es5.js:15595
at Array.forEach (<anonymous>)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15577)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26965)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26938)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26867)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
at Object.../../../../../src/main.ts (main.ts:11)
Meine Login-Komponente Sieht so aus
import { Component } from '@angular/Core';
@Component({
selector:'login-component',
templateUrl:'./login.component.html'
})
export class LoginComponent{}
app.- Modul.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common'
import { HttpModule } from '@angular/http';
import { ReactiveFormsModule} from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './main/app.component';
import {LoginComponent} from './login/login.component';
const appRoutes: Routes = [
{path:'', redirectTo:'login', pathMatch:'full'},
{ path: 'home', component: AppComponent },
{ path: 'login', component: LoginComponent }
];
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes),
],
declarations: [
AppComponent,
LoginComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Bekam ich diese Fehlermeldung, wenn ich versuche zu importieren LoginComponent in der Erklärung. Bin ich etwas fehlt hier.
InformationsquelleAutor Krishna | 2017-10-03
Du musst angemeldet sein, um einen Kommentar abzugeben.
Haben Sie einen Tippfehler in der import in Ihre
LoginComponent
's fileimport { Component } from '@angular/Core';
Es ist Kleinbuchstaben
c
, nicht Großbuchstabenimport { Component } from '@angular/core';
u muss eine Antwort bekommen. was war der Fehler
InformationsquelleAutor Almost Handsome
Nicht eine Lösung für das konkrete Beispiel oben, aber es gibt viele Gründe warum Sie diese Fehlermeldung erhalten. Ich habe es wenn ich versehentlich Hinzugefügt, ein Modul des Modul-Deklarationen Liste und nicht um Importe.
In der app.- Modul.ts:
InformationsquelleAutor andersh
Dem Oben genannten Fehler tritt auf, wenn eine falsche importieren, fertig.
Zum Beispiel manchmal-Service-Dateien Hinzugefügt werden können im TestBed.configureTestingModule.
Und auch beim importieren von Material-Komponente zum Beispiel den import von
nicht aus
InformationsquelleAutor harshith hanthur manjunath
Hatte ich eine Komponente deklariert, ohne die styleUrls Eigenschaft, wie das ist:
statt:
Hinzufügen in der styleUrls Eigenschaft das Problem gelöst.
InformationsquelleAutor Silviu Panait