angular - Handling null response from server -
i have ngif condition check response data. getting null response when there no data. want show "no data found " if it's null. tried ngif="!addresses"
it's not working how handle this? template:
<div class="col-md-9 col-sm-9 col-xs-9 *ngif="(!addresses )"> <div class="col-md-9 col-sm-9 col-xs-9"> no data found </div> </div>
component:
getdata(id){ this.service.getdata(id) .subscribe(addresses => this.addresses = addresses) this.oncehttp = !this.oncehttp; }
response : null
service:
getdata(id){ const eurl='http://localhost/angular/getdata.php?id=' const url= `${eurl}${id}` return this.http.get(url) .map(this.extractdata) .catch(this.handleerror) }
i getting null value server. can tell me doing wrong??
update:
you define empty
property in component follows:
getaddress(id){ this.dataservice.getaddress(id) .subscribe(addresses => this.addresses = addresses); this.oncehttp = !this.oncehttp; } empty(){ return this.addresses === null || this.addresses.length === 0; }
then use property in template as
<div *ngif="empty">//code show when addresses has no content</div>
Comments
Post a Comment