Advertisement
Randohinn

Notification Service

Jul 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Injectable, OnInit} from "@angular/core";
  2. import {Http, HTTP_PROVIDERS, URLSearchParams} from "@angular/http";
  3.  
  4. /**
  5.     AngularJS Service, to contain everything related to notifications.
  6. **/
  7.  
  8. @Injectable()
  9. export class NotificationService {
  10.     private user: Object;
  11.  
  12.     constructor(public http: Http) {
  13.         this.user = JSON.parse(Cookies.get("authed"));
  14.     }
  15.  
  16.     getAndDisplayNotifications() {
  17.  
  18.  
  19.     }
  20.    
  21.     dispatchNotificationToUser(message: String, action: String, type: String, callback: String) {
  22.         let body = {"owner": this.user.mail, "message": message, "action": action, "type": type, "callback": callback};
  23.         console.log(body);
  24.         this.http.post("example.com", JSON.stringify(body)).subscribe(
  25.             data => console.log(JSON.parse(data._body))
  26.         );
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement