小编zif*_*yan的帖子

角度等待不等待函数完成

我正在从 cordova 插件调用异步函数。然而等待并没有真正起作用。

export class MationLiteService implements IgatewayService {
  async getGroupAllInfo(gatewayId: string, account: string, decryptedpasswd: string) {

// some codes
        return await cordova.plugins.MationPlugin.getGroupAllInfo(data, async (response) => {

        const json: JSON = JSON.parse(response);
        console.log('responseaaaaa:' + response);
        return json;
      }, (error) => {
        console.log('error: ' + error);
      });
  }
}
Run Code Online (Sandbox Code Playgroud)

这是网关管理器类

export class GatewayManagerService {
 public  getGroupAllInfo(gatewayType: string, gatewayId: string, account: string, decryptedpasswd: string) {
    return this.gatewayFactoryService.getGateway(gatewayType).getGroupAllInfo(gatewayId, account, decryptedpasswd);
  }
}
Run Code Online (Sandbox Code Playgroud)

我就是这么称呼它的

  async getAllInfo2(){
     this.facadaService.GetGatewayManagerService().getGroupAllInfo('mation-lite', this.zifan, 'admin', '5555').then((response) => {
        console.log(response);
     }); …
Run Code Online (Sandbox Code Playgroud)

async-await typescript ionic-framework angular

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