kris14an kris14an - 4 years ago 159
AngularJS Question

Angular template directive binding

I wrote single file with directive templates. This file is appended to document using

directive. Sometimes browser load templates before directive template binding, but not always.

Is there some solution to wait after
directive apply html content to document and after that bind directive templates? Maybe should i use different solution to load these templates to html document.

Answer Source

Angular has 2 builtin possibilities:

  1. Yout template should be in file directly included in your 'index.html'. (Sync templates)
<script src="templates.js"></script>
in which:$templateCache) {
  $templateCache.put('templateId', '<div></div>')
  1. Each template should be in separate file template1.html, templat2.html... (Async templates)

P.S. During development templates are always in separate html files, for production usage templates are gathered to js files using build tools.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download