dimanche 26 octobre 2014

Put directive template as a content of container the directive is attached to


Vote count:

0




Normally, when i'm creating a directive, i have two possible ways to deal with directive templates. I can create a html file somewhere on my server and use it's URL in directive settings:



@directives.directive "someDirective", [
'$rootScope'
($rootScope) ->

controller: ($scope) ->

link: (scope, element, attrs) ->
return

restrict: 'A'
templateUrl: 'path/to/template.html'
scope: {
eventId: '@'
}
]


or i can put the script tag somewhere in the markup and use it's ID as a templateUrl:



<script type="text/ng-template" id="template.html">
<p>Hello {{ name }}</p>
</script>


However, i was wondering - is that possible to put that template to directive container tag as a body of it? That's how i want it to look:



<div my-ng-directive>
<p>Hello {{ name }}</p>
</div>


asked 34 secs ago

mbajur

1,197






Put directive template as a content of container the directive is attached to

Aucun commentaire:

Enregistrer un commentaire