我在打字稿中有一个函数,我发出一个HTTP请求,请求应该接收一个json作为响应,我收到json响应后,我想在我的HTML上显示数据。 示例代码:
打字稿:
this._httpProblemsService.submitVerifierTool(codeObject).subscribe(
data => {
if(data["status_server"] == "successful run" && data["status_student"] == "successful run"){
this.professorOutputTestCase = data["output_server"];
this.outputStudent = data["output_student"];
}
document.getElementById("outputStudent").innerHTML = this.outputStudent;
document.getElementById("outputServer").innerHTML = this.professorOutputTestCase;
}
);
这是HTML:
<!-- Verifier Tool tab -->
<tab-static tabTitle="Verifier Tool" boldTitle=true>
<h4><b>Verifier Tool</b></h4>
<div>Try here your test cases before submission</div>
<span>
<h4><b>Your Input:</b></h4>
<input placeholder="Your professor's input sample{{professorInputTestCase}}" id="student_input" type="text" class="form-control">
<h4><b>Expected Output:</b></h4>
<pre id="outputServer" class="white-space"> {{professorOutputTestCase}}</pre>
<h4><b>Your Output:</b></h4>
<pre id="outputStudent" class="white-space">{{outputStudent}}</pre>
<button type="button" class="btn btn-success"
(click)="verifierToolSubmitReceived()">Submit
</button>
</span>
</tab-static>
我知道:document.getElementById("outputStudent").innerHTML = this.outputStudent;
是一个javaScript实现,但是相当于使用TypeScript / Angular执行此操作?