Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { HttpClient } from '@angular/common/http';
- import { Injectable } from '@angular/core';
- import { Http, Headers} from '@angular/http';
- import 'rxjs/add/operator/map';
- import { SignUpContainer } from '../../pages/signup/signup.model';
- import { reject } from 'q';
- /*
- Generated class for the SignUpServiceProvider provider.
- See https://angular.io/guide/dependency-injection for more info on providers
- and Angular DI.
- */
- @Injectable()
- export class SignUpServiceProvider {
- url:string = "http://localhost:3800";
- data: any;
- constructor(public $http: Http) {
- console.log('Hello SignUpServiceProvider Provider');
- this.data = [
- {name:'Microsoft', code: 324, product: 'Windows 10'},
- {name:'Microsoft', code: 678, product: 'Windows 7'}
- ];
- }
- loadAll(){
- return Promise.resolve(this.data);
- }
- postData(registerContainer: SignUpContainer) {
- return new Promise((resolve, reject) => {
- this.$http.post(this.url + "/api/users/add",
- {
- "username": registerContainer.username,
- "password": registerContainer.password,
- "email": registerContainer.email,
- "name": registerContainer.name,
- }).subscribe(res => {
- resolve(res.json());
- console.log(res.json);
- }, (err) => {
- reject(err);
- });
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement