The docs (source) for template state:
replace the current element with the contents of the HTML.
Let's do this bit by bit.
replace the current element
First, shouldn't 'current element' change to 'the element on which the directive is declared'.
Then:
For the following element:
<my-directive>Original</my-directive>
This directive:
myApp.directive( 'myDirective', function() {
return {
restrict: 'E',
template: 'New'
}
});
Will result in:
<my-directive>New</my-directive>
So the current element isn't replaced at all (<my-directive>..</my-directive> is still there).
What am I missing here?
contents of the HTML
Which contents?
Isn't contents what's between tags? As in:
And which HTML?
Shouldn't it read:
Replaces the contents of the element on which the directive is declared with the markup provided in the template property.
Also:
The replacement process migrates all of the attributes / classes from the old element to the new one. See the Directives Guide for an example.
I don't really understand this and I couldn't find anything on the Directives Guide.
It really seems that the text applies more to the (deprecated) replace property, rather than template.