javascript - Angular.js load, process and display dynamic template obtained via REST $resource -


i have angular app needs support customizable reporting. intention allow user select 1 of many reports available , have end rest api provide template and data json (end user can customize template).

the app insert template somehow "reporting" view page put data in scope , angular should compile , display report / template.

i've looked ng-include seems support url or path document, have template text via rest service , cannot use static urls or file paths, needs via rest api, if ng-include accepted template text directly might work doesn't.

i've tried writing directive, trying call method on page (gettemplate()) load template fetched scope directive doesn't have access scope apparently.

what tactic should use accomplish this? directive seems best i'm doing wrong , lost in docs , many attempts trying accomplish this.

you compile dynamic template element on dom in controller , in controller have this:

var el = angular.element('#myselector');    el.html(mydynamichtmlfromresource);  $compile(el.contents())($scope); 

i setup route template single div container (you pull static container template in single javascript file using htmltojs online tool or grunt task):

<section class="view">   <div id="myselector"></div> </section> 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -