I am trying to create a text / ng template type script to put my error message template in $ templateCache. I want this script file to be deleted, it has its own file outside of HTML.
<script type="text/ng-template" id="error-messages">
<span ng-message="required">This field is required.</span>
<span ng-message="min">This number must be larger than {{min}}.</span>
<span ng-message="max">This number must be smaller than {{max}}.</span>
<span ng-message="number">A number is required.</span>
<span ng-message="date">A date is required.</span>
</script>
Then in HTML I want to reference this template, which I believe should be in $ templateCache, and I can access it by identifier.
<form name="userForm">
<div class="form-group">
<label for="requiredInput">Required</label>
<input type="text" class="form-control" id="required" name="requiredInput"
ng-model="user.required" required />
<div ng-messages="userForm.requiredInput.$error" ng-messages-include="error-messages"></div>
</div>
</form>
If I put a script embedded in HTML, it works fine, but I want it to be in a remote file. When I move it to a remote file, my HTML cannot find my template error messages.
This is my first Plunker I share. Please let me know if you cannot reach it.
http://plnkr.co/edit/NgSm7piaECWBab1LOmp3?p=preview