How to set embedded widget options via clint script

Saroj Patel
Tera Expert

How can we set embedded widget options via client script

HTML Templates

<div class="form-group">
<p>
Embedded widget via Client Script
</p>
<sp-widget widget="c.clientScriptWidget"></sp-widget>
</div>

 

Client Script

function(spUtil){

spUtil.get('widget-cool-clock').then(function(response){
c.clientScriptWidget=response;
});
}

 

 

function(spUtil){ 

spUtil.get('widget-cool-clock',{c_color:"orange"}).then(function(response){  //not working
c.clientScriptWidget=response;
});

7 REPLIES 7

This works for widget-cool-clock where the options are c_color. How can this be adapted where embedded widget is a simple-list-widget and the options to be added are 'table='incident'' ?

thank you very much

shamil-ibrahim
Tera Expert

If anybody still didnt find solutions for this, you can try below.

 

create a rootscope variable in the main widget client controller:

api.controller = function($scope, $rootScope) {
$rootScope.variable_name = "Some Value";
spUtil.get("embedded_widget_id").then(function(response) {
			$scope.embedded_widget = response;
		});
}

Add the ng-template to the HTML of main widget, you can also create new ng-template record as well:

<script type="text/ng-template" id="embedded_widget_template">
    <sp-widget widget="embedded_widget"></sp-widget>
</script>

Now call the widget without any options and within the embedded widgets client controller you can access the variable value as below:

 

spUtil.addInfoMessage($rootScope.variable_name);