ng-if condition

Brook3
Giga Expert

Hello Experts,

 

I struggle with "ng-if" condition.

if it's NOT assigned to me, the button will be displayed.

 

 

HTML

<button type="button" class="btn btn-default" ng-click="c.uiAction('assign_to_me',current.sys_id)" ng-if="!current.user == current.assigned_to">Assign to Me</button>  

 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Assuming this is about the user and assigned_to fields like you mentioned in your example:

Can you try:

ng-if="current.user != current.assigned_to"

Because you do mention, not assigned to me, I would expect something with using gs.getUserID(). Can you verify?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Assuming this is about the user and assigned_to fields like you mentioned in your example:

Can you try:

ng-if="current.user != current.assigned_to"

Because you do mention, not assigned to me, I would expect something with using gs.getUserID(). Can you verify?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Oh thank you!!!

Rishabh Jha
Mega Guru

Hi,

You'd need to change it to below, and it should work -

<button type="button" class="btn btn-default" ng-click="c.uiAction('assign_to_me',current.sys_id)" ng-if="current.user != current.assigned_to">Assign to Me</button>  

 

Thanks & Regards,

Rishabh Jha

Aavenir (https://www.aavenir.com/)

Thank you for your reply!