① create a service class
@Injectable()
Service class defined in the method, the data
sendRequest ( myUrl : string ) {
return this.http.get( myUrl ).map( (response : Response) => response.json() )
}
② to the designated service provider
providers: [MyHttpService] module assembly defines a scope
③ call service
import { }
this.myHttpService.sendRequset ( 'address request') .subscribe ((result: any) => {console.log (reuslt)})