javascript - How to make a directive for adding sections in angular at runtime based on attribute value -


i have many sections

and accordingly have different code maintained in html files home.html , about.html , want make angular custom directive render @ runtime

and had tried making directive works first time not when using multiple times . need making directive

app.directive('mysection', function() { return {    restrict: 'e',    transclude:true,    templateurl: function(elem,attrs) {        return "sections/"+attrs.templateurl +".html"    } } });     

and in html writing

<mysection template-url="headersection"><mysection> <mysection template-url="headersection"><mysection> 

try markup

<mysection template-url="headersection"></mysection> <mysection template-url="headersection"></mysection> 

note close tag


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -