Check out this template I created:
<script type="text/ng-template" id="validationErrors.html">
<div id="validationErrors">
<div id="errorListContainer">
<h2>Your order has some errors:</h2>
<ul>
<li ng-repeat="error in validationErrors">{{error.message}}</li>
</ul>
</div>
</div>
</script>
Here's the code snippet I've been working on:
var errors = [...];
var template = $templateCache.get("validationErrors.html");
var link = $compile($.trim(template));
var scope = $rootScope.$new(true);
scope.validationErrors = errors;
var linked = link(scope);
alert();// What should be placed inside these parentheses?
scope.$destroy();
My question is, how can I convert the linked element into a string so that the ng-repeat directive displays the list of errors?
If I try this...
linked.html();
...I end up with the following result even though there are validation errors present...
<DIV id=errorListContainer>\r\n<H2>Your order contains invalid fields:</H2>\r\n<UL><!-- ngRepeat: error in validationErrors --></UL></DIV>