Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Http } from '@angular/http';
- import 'rxjs/add/operator/map';
- /*
- Generated class for the RestapiService provider.
- See https://angular.io/docs/ts/latest/guide/dependency-injection.html
- for more info on providers and Angular 2 DI.
- */
- @Injectable()
- export class ApitransaksiService {
- host : string = 'http://localhost/sss/index.php/ApiTransaksi';
- param : any;
- url : any;
- constructor(public http: Http) {
- console.log('Hello RestapiService Provider');
- this.param = {};
- this.url = '';
- }
- public getHost(){
- return this.host;
- }
- public loadTransaksi(param){
- this.param = param;
- this.url = this.host;
- return this.getData();
- }
- public viewTransaksidetil(param){
- this.param = param;
- this.url = this.host +'/index/detail/id_pemesan/' + param.id_pemesan;
- return this.getData();
- }
- /*public viewReservasi(param){
- this.param = param;
- this.url = this.host2 +'/index/id_user/' + param.id_user;
- return this.getDataReservasi();
- }*/
- public transaksiList(param){
- this.param = param;
- this.url = this.host;
- return this.getData();
- }
- private getData() {
- let param = {
- data : this.param
- };
- return new Promise(resolve => {
- this.http.get(this.url,param).subscribe(data => {
- //let r = data.json();
- resolve(data.json());
- },
- err => {
- //let r : any = err;
- //let parse = JSON.parse(r._body);
- resolve(err.json());
- });
- });
- }
- /*private getDataReservasi() {
- let param = {
- data : this.param
- };
- return new Promise(resolve => {
- this.http.get(this.url,param).subscribe(data => {
- //let r = data.json();
- resolve(data.json());
- },
- err => {
- //let r : any = err;
- //let parse = JSON.parse(r._body);
- resolve(err.json());
- });
- });
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement