小编NAM*_*AMS的帖子

Calling a service in a service and returning async result?

Using Angular 5. A component calls a service. This service must call another service before making a server call. I am not able to get the result asynchronously in the component. I use ellipses for brevity below.

Component:

...
import { SystemOnlineService } from '../services/system-online.service';
...
constructor(private sys: SystemOnlineService) {
    sys.getStatus()
    .then(result => {
        console.log(result);
    });
}
Run Code Online (Sandbox Code Playgroud)

SystemOnlineService:

import { Injectable } from '@angular/core';
import { Wakanda } from './wakanda.service';
import 'rxjs/add/operator/toPromise';
...
getStatus() {

    this.wakanda.getCatalog()
    .then((ds) => {
        this.ds …
Run Code Online (Sandbox Code Playgroud)

wakanda angular

0
推荐指数
1
解决办法
117
查看次数

标签 统计

angular ×1

wakanda ×1