Dynamic embed widget instance in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:13 AM
Hi guys,
I am trying to embed a widget instance like shown here
Embed Widget Instance · Issue #28 · service-portal/documentation · GitHub
This works : <widget rectangle="my_incidents"></widget>
But I'd like to be able to do it within a loop of widgets' instances.
Like <widget rectangle="{{instance.id}}"></widget>
And that doesn't work.
Can anyone help ?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:19 AM
Hi Tony,
Have you tried just using "instance.id" for the rectangle attribute? AngularJS has an interesting way of interpreting strings as variables at times you wouldn't expect. It's nice - in a way - and can bit you at other times. Give this a try.
<widget rectangle="instance.id"></widget>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:25 AM
Thanks Chuck,
I just did and it's not interpreting it.
With the quotes I have: `<sp-widget widget="data['my_incidents']" class="ng-isolate-scope"></sp-widget>`
Without the quotes: `<sp-widget widget="data['instance.id']" class="ng-isolate-scope"></sp-widget>`

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:38 AM
Try using server side.
<div ng-repeat="clock in data.clockOptions">
<sp-widget id="clock.id"></sp-widget>
</div>
(function() {
data.clockOptions = []; // Define the array of sp_widget table.
})();
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:48 AM
Hi Akhil,
Thanks for that but thing is I am trying to reference an instance of a widget. Not a widget. (Thus using the widget and not the sp-widget directive)
Or are you saying I should loop over my instances on the server side to get the options and build that data.clockOptions ? How can I do that?