Can not get the sent Options of the embedded widget

Serkan Yilmaz
Tera Expert

Hi,

I created a new widget with an embedded widget. I'm trying to sent params from the new widget to the embedded widget.

1) Parent widget:

HTML:

<div class="embedded-widget">

      <sp-widget widget="c.processflow"></sp-widget>

</div>

Client controller:

spUtil.get("process-flow", {table:"change_request"}).then(function(response) {

                  c.processflow= response;

      });

2) Embedded widget:

Client controller:

console.log("Table: "+c.options.table);

Server script:

console.log("table: "+input.options.table +" - "+options.table);

All of these results for "console.log" are undefined.

Cheers,

Serkan

12 REPLIES 12

Community Alums
Not applicable

Yes, I can give some examples. In the screenshot below, you see that there are several "cards" that are repeated at the bottom of the page:


ss2.png



The HTML for these is just one line:


find_real_file.png


I had an array, and i wanted to create a card for each item in the array. The array was an array of objects.



I use ng-include to create a template for each item in the array


find_real_file.png


find_real_file.png



As you can see, the object (offering, in this case) contains any unique information necessary to each card. You can see in the second line where I access the widget options.


ChrisBurks
Mega Sage

If using spUtil to embed a widget, you would pass options like the following using your example:





spUtil.get("process-flow", {table:"change_request"}).then(function(response) {


                  c.processflow= response;


                  c.processflow.options = {"table": "change_request"}


      });


You are correct Chris, but I need to send options multiple time, because a have a ng-repeat in the HTML part and I'm embedding the widget in the ng-repeat.


Is there a way to use server side to embed your widget? If so this will work:



var opts = [


  {"table": 'table info 1'},


  {"table": 'table info 2'}


  ];


  data.embedWid = [];



  for(i in opts){


  data.embedWid.push($sp.getWidget('process-flow', opts[i]));


  }



<div ng-repeat="widg in data.embedWid">


        <sp-widget widget="widg"></sp-widget>


</div>


How about this:



HTML Template:



<div ng-repeat="process in process_widgets">


        <sp-widget widget="process"></sp-widget>


</div>





Client Controller:


var opts = [


  {"table": 'table info1'},


  {"table": 'table info2'}


  ];



$scope.process_widgets = [];



  for( i in opts ){


            getProcessWidget(opts[i]);


  }




  function getProcessWidget(opt){


            spUtil.get('process-flow').then(function(response){


                      var process = response;


                      process.options = opt;


                      $scope.process_widgets.push(process);


            })


  }



Of course you'll more than likely need to create your options array in a different manner.


Hope this helps