How do I hide a service portal widget if a viewer is logged in?

Garrett2
Tera Expert

I'm working on our home page and we're showing articles to logged in users, but not to logged out users. This makes the homepage pretty empty to people who aren't logged in. 

I've been working on a widget that will just show some marketing text, but I can't get the angular JS to work.

Any advice on how I can hide or show a widget depending on a person's logged in status?

1 ACCEPTED SOLUTION

Pranav Bhagat
Kilo Sage

Basically use ng-if.

 

In the below example the data will only show when the myVar is true(If the user is logged in)

If you only want to show it to non logged in, reverse the condtion

 

<div ng-if="!myVar">

 

HTML

 

<div ng-if="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
<hr>
</div>

 

 

Server Side

 

data.myVar = gs.isLoggedIn();

 

Regards

Pranav

View solution in original post

3 REPLIES 3

Pranav Bhagat
Kilo Sage

Basically use ng-if.

 

In the below example the data will only show when the myVar is true(If the user is logged in)

If you only want to show it to non logged in, reverse the condtion

 

<div ng-if="!myVar">

 

HTML

 

<div ng-if="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
<hr>
</div>

 

 

Server Side

 

data.myVar = gs.isLoggedIn();

 

Regards

Pranav

Thanks for the help Pranav, this did it!

Vinita Jain2
Giga Contributor
how to remove empty space when the widget is hidden based upon role in service portal?