У меня есть этот образец JSON Формат данных из нашего API
{
"type": "BasicResponse",
"name": "",
"serverId": "",
"requestId": "",
"output": {
"Result": {
"ListSequence": [
{
"status": "ORDER PROCESSED",
"date": "",
"comment3": "",
"comment4": "",
"comment1": "",
"time": "",
"comment2": ""
},
],
"RESULT": "SUCCESS"
}
},
"status": {
"success": true,
"returnCode": 0
}
}
Я хочу отображать значение только для всего статуса (например, ЗАКАЗАТЬ ОБРАБОТАНО), пока он отображается так в моем html страница Кстати, я следовал за этим гидом .
Вот моя страница.ts
constructor(private dataService: DataService, private http: HttpClient) {
this.data = '';
this.error = '';
}
private prepareDataRequest(): Observable<object> {
// Define the data URL
const dataUrl = '';
// Prepare the request
return this.http.get(dataUrl);
}
ionViewWillEnter() {
// Load the data
this.prepareDataRequest()
.subscribe(
data => {
// Set the data to display in the template
this.data = JSON.stringify(data);
},
err => {
// Set the error information to display in the template
this.error = `An error occurred, the data could not be retrieved: Status: ${err.status}, Message: ${err.statusText}`;
}
);
}
Вот моя страница. html
<p *ngIf="!error;else errorContent">{{ data ? data : '-' }}</p>
<ng-template #errorContent><p><span style="color: red;">{{error}}</span></p></ng-template>