javascript - Mustache.js to Angular.js, triple bracers in Angular? -


i have following in mustache.js:

<div>{{{icon.tmpl}}}</div> 

icon.tmpl template on own following content:

<div id="{{id}}" class="glyphicon glyphicon-send"></div> 

in mustache.js, triple bracers, works perfectly, both levels of templates gets compiled. can't make work in angular.js. second embedded template not compiled, instead surrounded quotation marks "..."

how make work in angular?

you either use nginclude or create directive. here example of icon directive replaces icon element div info you've specified.

http://plnkr.co/edit/nk5bofvsgpmgetktemif?p=preview

html:

<icon></icon> 

js:

app.directive('icon', function ( $compile, $timeout) {         return {             restrict: 'ea',             replace: true,             template: '<div id="{{id}}" class="glyphicon glyphicon-send"></div>'         }      }) 

the directive <div class="icon"> or <div icon> , apply template it.

an example of nginclude:

<ng-include src="'icon.html'"></ng-include> 

where icon.html has template info. make sure id in scope in both cases.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -