angular - Angular2 How can I use ngIf correctly to show some text only when there's no data from server? -


i getting data server , using ngfor show them (it's search feature) when there's no result, want show text saying 'there's no result"

how can this?

i tried far isn't working.

 <div *ngif="teainfo != '{}'">          <div class="starter-template text-xs-center">             <h5 style = "text-align:center">no result</h5>          </div>     </div> 

use ngswitch check data exist , show default message if no data available below:

you can below result of if statement advisable use switch instead of if statement better performance perspective.

<div [ngswitch]="true">     <div *ngswitchcase="teainfo != null && teainfo.length>0">         //perform operation on data     </div>     <div *ngswitchdefault>          there's no result                       </div> </div> 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -