angular - angular2 - show hide if value is empty -


here have 2 container, first container suppose show if value exist in json , second 1 show value empty json. here code:

app.component.html

<!-- show container if value exist -->     <ng-container *ngif="outletname">   <div class="media media-xs align-items-center mb-5">     <div class="media-right float-right">       <a class="drop-assigned-outlet" href="#"><i class="fa fa-trash-o"></i></a>     </div>     <button class="btn btn-primary-ln" *ngif="outletname">change assigned outlet</button>x   </div> </ng-container>  <!-- show container if value empty --> <ng-container *ngif="outletname == ''">   <div class="media media-xs align-items-center mb-5">     <p>no outlet have assigned</p>   </div>   <button class="btn btn-primary-ln">assign outlet</button> </ng-container> 

data.json

[   {     "staffid": "59998eeadfb23a8c0bba5769",     "staffname": "sutton fitzpatrick",     "outletname": "marjorie fitzgerald",     "outletid": "59998eeaf84372166a233235",     "outletlocation": "mid valley, kl",     "designation": "outlet supervisor",     "image": "http://placehold.it/100x100",     "activesince": "2015-06-27t09:29:23 -08:00",     "deactivatedsince": "2015-12-07t12:05:04 -08:00",     "status": "active",     "email": "samuelkavin@yahoo.com",     "contact": 60124174701,     "devices": [       {         "posname": "outlet1_device00001",         "deviceid": "59998eea245ec74623bfb06c",         "lastactive": "04:50:34"       }     ]   } ] 

app.component.ts

ngoninit() {      let staffdetail = localstorage.getitem('editstaff');     let staff = json.parse(staffdetail);      this.outletname = staff.dataitem.outletname;     this.outletlocation = staff.dataitem.outletlocation;     this.image = staff.dataitem.image; } 

change first to

<ng-container *ngif="outletname !== ''"> 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -