将响应存储在来自 api 调用的变量中

问题描述 投票:0回答:0

我不会将来自 api 调用的数据存储在变量中并在订阅之外使用它

GetAges(): Observable<string[]> {
    var url = this.SharedURL + '/ageGroupLocal?lang=' + this.lang;

    return this.http.get<string[]>(url);
  };

这是我的服务,我想在变量中存储响应并在 component.ts 中使用它

angular observable subscribe
© www.soinside.com 2019 - 2024. All rights reserved.