I have had this error for over a day and I am not sure why.
app.module
import {NgModule} from "@angular/core";
import {BrowserModule} from "@angular/platform-browser";
import {AppComponent} from "./app.component";
import {FormsModule} from "@angular/forms";
import {LoginComponent} from "./Login/login";
import {LoginService} from "./Login/login.service";
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent,
LoginComponent],
providers:[LoginService],
bootstrap: [AppComponent]
})
export class AppModule {
}
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '<login></login>'
})
export class AppComponent {
}
login.model.ts
export class LoginModel{
private userName: string;
private password: string;
constructor(userName: string='', password: string=''){
this.userName = userName;
this.password = password;
}
}
login.ts
import {Component} from '@angular/core';
import {LoginModel} from "./login.model";
import {LoginService} from "./login.service";
@Component({
moduleId: module.id,
selector: 'login',
templateUrl:'./login.html',
styleUrls:['../css/styles.css'],
})
export class LoginComponent{
login:LoginModel = new LoginModel();
constructor(public loginService:LoginService){
}
onSubmit() {
this.loginService.output();
}
login.service
import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';
@Injectable
export class LoginService {
output(){
console.log("You are in the service output class...");
}
}
Currently I am just trying to get the application to compile so I can creating the routes and services. That was the whole point of the project but I keep hitting walls. Any advice will be greatly appreciated.
GitHub Link
In my case login.service.ts was missing the ()
in Injectable()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments