I currently learning Angular 5 and I'm having difficulty on passing data from a service to a component. I'm integrating this to wordpress..
here's my current code:
orderers.component.ts
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-orderer',
templateUrl: './orderer.component.html',
styleUrls: ['./orderer.component.css'] })
export class OrdererComponent implements OnInit {
o_manual:boolean = false;
orderers = [];
constructor(private http:HttpClient) { }
ngOnInit() {
this.get_users();
}
get_users() {
this.http.get('http://ift.tt/2A7ZARM').subscribe( data => {
this.orderers = data;
}
} }
how can i transfer get_user() to a service and return the data and pass it in the component ? Thanks .. :)
Aucun commentaire:
Enregistrer un commentaire