在引导面板中显示时,文本格式正在更改

时间:2019-06-23 13:30:12

标签: angular bootstrap-4

我试图使用Github api从我的Github存储库中获取一个Java文件的数据,并在我的角度应用程序的UI面板中显示。 问题是它在控制台中以正确的格式打印,但是当它在应用程序中显示时,却像大字符串一样显示。

该组件正在调用github.service.ts的getCode方法来获取数据并设置要在UI页面中呈现的对象Question。

github.service.ts getCode方法

getCode(url: string){

    return this.http.get(url)
        .subscribe(
            (response)=>{
                console.log('-----------------getCode-----------');
                console.log(atob(response.json().content));
                this.questionDetails = new Question(response.json().name,response.json().url,
                    response.json().html_url,atob(response.json().content));
                console.log('questionDetails:'+this.questionDetails.name+"::"+this.questionDetails.url)    
            }
        )
}

用于呈现数据的UI。

<div class="container-fluid">
    <div class="row">
      <div class="col col-xl-12">
        <p *ngIf="isFetching"> Loading...</p>
        <div class="panel panel-primary" *ngIf="!isFetching">
            <div class="panel panel-heading">{{ questionDetails.name }}</div>
            <div class="panel panel-body">{{  questionDetails.code 
            }}</div>
        </div>
      </div>
    </div>
</div>

questionDetails.code是Java文件内容的值。enter image description here

0 个答案:

没有答案
相关问题