Our application should support user registration. We already have the backend logic for this functionality. Now, all we have to do is tie it up with our Angular application. To do this, we are going to create a generic module called auth
, which will be used for both registering and authenticating users.
We will continue with the auth
service, which will hold all the communication logic with the Node.js backend application. Create a file called public/src/auth/services/auth.service.ts
and implement the entire logic of the service by following these steps:
Import the dependencies:
import { Injectable } from 'angular2/core'; import { Http, Response, Headers } from 'angular2/http'; import { Subject } from 'rxjs/Subject'; import { BehaviorSubject } from 'rxjs/Subject/BehaviorSubject'; import { contentHeaders } from '../../common/index';
Define the service class:
@Injectable() export class AuthService { public currentUser: Subject<any>; private _http: Http...