# How to hide HTML template if a variable value is null

**URL:** <https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496>\
**Category:** ionic-v3\
**Created:** [May 2, 2018, 9:56am UTC](https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496 "2018-05-02T09:56:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flycoders\_sourav](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@flycoders\_sourav](https://forum.ionicframework.com/u/flycoders_sourav)\
**Post date:** [May 2, 2018, 9:56am UTC](https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496/1 "2018-05-02T09:56:08Z")

</div>

How to hide HTML template if a variable value is undedfined/null  
below my json response

| guardReport\_id | 27 |
| --- | --- |

```auto
|user_id|42|
|guard_time1|09:39|
|guard_location1|North fence|
|guard_cmnt1|sasa|
|guard_time2|null|
|guard_location2|null|
|guard_cmnt2|null|
|guard_time3|null|

```

I do not want to see the null values in my html template  
Thanks

---

<div class="post-metadata">

**Author:** ![bevangelisti](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bevangelisti/32/118997_2.png) [@bevangelisti](https://forum.ionicframework.com/u/bevangelisti)\
**Post date:** [May 2, 2018, 1:02pm UTC](https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496/2 "2018-05-02T13:02:57Z")

</div>

Hi, @flycoders_sourav, try:

```auto
<div *ngIf="guard_time2">{{ guard_time2 }}</div>

```

Cheers!

---

<div class="post-metadata">

**Author:** ![Morad-Abdelgaber](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Morad-Abdelgaber](https://forum.ionicframework.com/u/Morad-Abdelgaber)\
**Post date:** [May 3, 2018, 1:36am UTC](https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496/3 "2018-05-03T01:36:46Z")

</div>

Use \*ngIf directive in div tag

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:37pm UTC](https://forum.ionicframework.com/t/how-to-hide-html-template-if-a-variable-value-is-null/129496/4 "2021-07-19T21:37:20Z")

</div>


