Widget ng-include not pulling in template

krr
Mega Guru

We're trying to use a template within a widget for the service portal and even the simplest example is not working, so there must be a step I'm missing.

From examples in the system with OOTB widgets they use this to pull in the template

<div ng-include="template_id"></div>

When doing the same thing for a simple example below, the template doesn't load. What's the proper method to pull in a ng-template?

HTML Template

<div>
  <h1>This is a widget</h1>
  <div ng-include="test"></div>
</div>

Client Script

function() {
  /* widget controller */
  var c = this;
}

Server Script

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */

})();

Angular ng-template: test

<strong>Hello world!</strong>

HTML Output

<div> 
 <h1>This is a widget</h1> 
 <!-- ngInclude: test --> 
</div>

Output screenshot

find_real_file.png

1 ACCEPTED SOLUTION

It should also work like:

<div ng-include="'test'"></div>

View solution in original post

8 REPLIES 8

In my own instance I am able to get it to work like so:

<div data-ng-include="'test'"></div>

It should also work like:

<div ng-include="'test'"></div>

With the template id as test this works

<div data-ng-include="'test'"></div>

Apparently it needed the single quotes, it doesn't work without them.

Prateek kumar
Mega Sage

Take a look at the below article:

Please mark my response as correct answer and helpful if it helped solved your question.
-Best Regards
Prateek kumar


Please mark my response as correct and helpful if it helped solved your question.
-Thanks