Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Injectable, Inject} from 'angular2/core';
- import {Http, Headers} from "angular2/http";
- export interface User {
- firstname: string;
- lastname: string;
- email: string;
- password: string;
- subjects: [
- {
- subject: {
- name: string;
- code: string;
- }
- role:string;
- tasks: [number];
- }
- ]
- }
- @Injectable()
- export class IUserService {
- user: User;
- http: Http;
- contructor(@Inject(Http) http: Http) {
- this.getUserInit();
- }
- getUserInit() {
- return this.http
- .get('/user', localStorage.getItem('token'))
- .map((res : any) => {
- console.log(res);
- let data = res.json();
- this.user = data.user;
- localStorage.setItem('user', JSON.stringify(this.user));
- });
- }
- getUser() {
- return this.user;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement