Dynamic embed widget instance in Service Portal

tonycosentino
Kilo Contributor

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

5 REPLIES 5

Chuck Tomasi
Tera Patron

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>


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>`


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.


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?