- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 08:44 AM
Im trying to output a list in the service portal but at the moment nothing is being returned. The questions is I know the server script is returning values but how do I access them in the HTML of my widget
this is my html
<div>
<ul>
<li ng-if="c.data.list.length > 0" ng-repeat="item in c.data.list">{{::todo.title}}</li>
</ul>
</div>
this is my server side script - Ive used logs to confirm the query returns values.
var getTodos = new GlideRecord('u_todo');
getTodos.orderByDesc('u_order');
getTodos.setLimit(5);
getTodos.query();
data.list = [];
while(getTodos.next()){
var todo = {};
gs.info("|>>>before" + getTodos.getDisplayValue('u_title') + " " + getTodos.getDisplayValue('u_url'));
todo.title = getTodos.getDisplayValue('u_title');
todo.url = getTodos.getDisplayValue('u_url');
gs.info("|>>>after" + todo.title + " " + todo.url);
data.list.push(todo);
}
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 10:10 AM
I fixed this
<ul>
<li ng-if="c.data.list.length > 0" ng-repeat="item in c.data.list">
<a href="{{::item.url}}"><i class="fa fa-chevron-right m-r-sm"></i> {{::item.title}}</a>
</li>
</ul>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 10:10 AM
I fixed this
<ul>
<li ng-if="c.data.list.length > 0" ng-repeat="item in c.data.list">
<a href="{{::item.url}}"><i class="fa fa-chevron-right m-r-sm"></i> {{::item.title}}</a>
</li>
</ul>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 10:32 AM
Hi Salzo.
Good to see you solved your own question 🙂
Perhaps it would be even better to move the ng-if to the <ul> and do the check there. That way the <ul> will not be put in your page at all if the array has no items to show 🙂
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 11:07 AM
btw, as your question was answered by yourself, set your answer as best answer so that others can see the question was answered, because I looked at your question thinking it was not answered as well. Thanks!