I want to call a service imported in my @ngModule from a login component. This what i did but it's not working. I have just started to work on the A2 final version.
export class Login implements OnInit{
constructor(
private _service: Service
) {
}
ngOnInit() {
this._service.login(value)
.subscribe(x => console.log(x));
}
}
}
My @ngModule
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { LoginService } from '../service/login.service';
import { Login } from './login.component';
export const routes = [
{ path: '', component: Login, pathMatch: 'full' }
];
@NgModule({
declarations: [
Login
],
imports: [
CommonModule,
RouterModule.forChild(routes)
],
providers: [LoginService]
})
export default class LoginModule {
static routes = routes;
}
Any ideas ?