I am stuck in a situation here. I am getting an error like this.
compiler.es5.js:1694 Uncaught Error: Unexpected value \'LoginComponent\' declared by the modul
In my case I mistakenly added this:
@Component({
selector: 'app-some-item',
templateUrl: './some-item.component.html',
styleUrls: ['./some-item.component.scss'],
providers: [ConfirmationService]
})
declare var configuration: any;
while the correct form is:
declare var configuration: any;
@Component({
selector: 'app-some-item',
templateUrl: './some-item.component.html',
styleUrls: ['./some-item.component.scss'],
providers: [ConfirmationService]
})
The Above error occurs if any wrong import done. For example sometimes Service files may be added in TestBed.configureTestingModule. And also while importing Material component for example import from
import {MatDialogModule} from '@angular/material/dialog'
not from
import {MatDialogModule} from '@angular/material'
I was trying to use BrowserModule in a shared module (import and export). That was not allowed so instead I had to use the CommonModule instead and it worked.
You have a typo in the import in your LoginComponent
's file
import { Component } from '@angular/Core';
It's lowercase c
, not uppercase
import { Component } from '@angular/core';
Another solution is below way and It was my fault that when happened I put HomeService
in declaration section in app.module.ts
whereas I should put HomeService
in Providers section that as you see below HomeService
in declaration:[]
is not in a correct place and HomeService
is in Providers :[]
section in a correct place that should be.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './components/home/home.component';
import { HomeService } from './components/home/home.service';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
HomeService // You will get error here
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule
],
providers: [
HomeService // Right place to set HomeService
],
bootstrap: [AppComponent]
})
export class AppModule { }
hope this help you.