When looking at the AngularJS documentation, you will come across an example using the templateUrl
property:
In the HTML:
//ngApp...
<div ng-controller="Ctrl">
<div my-customer></div>
</div>
And in the controller:
....directive('myCustomer', function() {
return {
templateUrl: 'my-customer.html'
};
})
The file my-customer.html is an external file:
Everything seems to be working fine, but there is also an option to edit it using jsfiddle:
However, in the example provided, it is treated as a template tag:
<div ng-app="docsTemplateUrlDirective">
<div ng-controller="Ctrl">
<div my-customer></div>
</div>
<!-- my-customer.html -->
<script type="text/ng-template" id="my-customer.html">
Name: {{customer.name}} Address: {{customer.address}}
</script>
</div>
Question:
How does Angular know whether it's dealing with an external file or an element ID? And is there a way to specify the type?
(p.s. - This information wasn't found in the docs).