I've created a custom directive.
<foo>
</foo>
Is there any way to access html within these tags ? For example
<foo>
<div>
....
</div>
</foo>
I want to access this div in my JS.
You need to use a ngTransclude
https://docs.angularjs.org/api/ng/directive/ngTransclude
.directive('foo', function(){
return {
restrict: 'E',
transclude: true,
template: '<ng-transclude></ng-transclude>'
};
Why not use the data-attr syntax?
<div data-foo>
<div></div>
</div>
And from the comments: You can inject $element and access or copy it's contents.