Hide an element in a DIV

mkader
Kilo Guru

Hello,

I am new to ServiceNow and Angular.

How can I hide a <div> on a widget through the portal?

I am able to not populate info to the <div>, but it just adds a big blank space.

what I have is:

<div ng-if="!c.data.accounting" ng-bind-html="c.data.marketing"></div>

I want to also perform a hide on this <div>

THanks!

 

 

6 REPLIES 6

Sukraj Raikhraj
Kilo Sage

Solution 1:

<div *ngIf="show" class="row container-fluid"  id="divshow" >
        Div Content
    </div>

Solution 2:

<div [hidden]="!show" class="row container-fluid"  id="divshow" >
            Div Content
        </div>

@Sukraj Raikhraj - I have server side JS that is checking my JSON Object set in the Instance Page Editor. If the values exist in the JSON, that data gets populated. If not, the data does not. This is to prevent creating multiple widgets across the several portals we have. 

I do something very simple in the server-side script by setting the values and then passing then binding them to my widget:

Server-Side Script:

(function() {

    data.marketing = options.marketing;

})();

I want to write a function that checks if this value is true, and if it is true, I want to show my <div> and if it is false, I want to hide my <div>