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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -