小编jus*_*ech的帖子

使用 xml2js 在 Angular 6 中未定义 parseString

到目前为止,我无法使用 Angular 6 让 xml2js 代码正常工作。我有一个 service.ts 返回 xml,但是当调用 xml2js.parseString 转换为 json 时,我始终收到未定义的错误。

“core.js:1673错误TypeError:无法读取未定义的属性'parseString'”

服务.ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, filter, catchError, mergeMap } from 'rxjs/operators';
import { HttpHeaders } from '@angular/common/http';

export interface Zid {
  zpid: number;
}
const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/x-www-form-urlencoded',
  }),
  responseType: 'text' as 'text'
};    

@Injectable({
  providedIn: 'root'
})

export class CdataServiceService {

  constructor(private …
Run Code Online (Sandbox Code Playgroud)

xml json typescript xml2js angular

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

标签 统计

angular ×1

json ×1

typescript ×1

xml ×1

xml2js ×1