Nativescript-angular after http service call, view is not updated (Angular 5 ).
Find the below code where I have written the http service call then the response is assigned to view which is not updating in view page. If I do any other event like mouse over text box, the view is getting updated. componet.ts file
this.orderService.getProductBySKU('DR1056.01534XXL')
.subscribe(resProduct => {
this.ngZone.run(() => {
this.processing = false;
});
}
Service file
getProductBySKU(sku) {
const authToken = localStorage.getItem('currentUserToken');
return this.http.get(this.config.apiUrl + 'get-product-by-sku?sku=' + sku, this.config.basicAuth())
.map(response => response);
}
Note : By default this.processing is given as True in constructor which displays in view, after service call this.processing is assigned as False, but which displays only True. If I click any text box or button click, this.processing is changed to False in view.
First off I'd recomend using the HttpClient params option to avoid potential URL escaping problems:
this.http.get(this.config.apiUrl + 'get-product-by-sku', {...this.config.basicAuth(), params: { sku: sku }})
```
As for the processing, try forcing a change detection:
constructor(private ref: ChangeDetectorRef) {}
(...)
this.orderService.getProductBySKU('DR1056.01534XXL')
.subscribe(resProduct => {
this.ngZone.run(() => {
this.processing = false;
this.ref.detectChanges();
});
}
If that doesn't work, please provide a snippet of your template.