- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2016 08:18 PM
Does anyone know how to compile these local widget 'ng-templates' through the controller, instead of through the view?
View - works
<div ng-include="'_xxxtemplatexxx_'"></div>
Outputs: "template"
Controller - Doesn't work
var compiled = $compile("<div ng-include=\"'_xxxtemplatexxx_'\"></div>")($scope);
console.log(compiled[0]);
Outputs: object with no "nodes" i.e empty.
When using $complie the basic template content isn't 'compiled' even if plain text is within it. Any ideas?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2016 09:45 PM
Thanks Siva, I managed to figure it out. Wrapping it with another element [div] was key in getting it to work also.
var compiled = $compile("<div><ng-include src=\"'_xxxtemplatexxx_'\"></ng-include></div>")($scope);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2016 09:36 PM
Hello Scott, I haven't tried but what you are trying is not even a common practice in AngularJS let alone Service Portal. See this
javascript - how can we use $compile outside a directive in Angularjs - Stack Overflow and see if that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2016 09:45 PM
Thanks Siva, I managed to figure it out. Wrapping it with another element [div] was key in getting it to work also.
var compiled = $compile("<div><ng-include src=\"'_xxxtemplatexxx_'\"></ng-include></div>")($scope);