ng-template和html2js两种不同的模板方式

bg-template方式,这种方式在浏览器加载html时会将模板置入$templateCache中
<script type="text/ng-template" id="/tpl.html">
 
     Content of the template.
 
 </script>
在启用了$templateCache的$http ajax请求, angular将会首先在$templateCache中查找是否有对此url的缓存
如果有  则不会发起ajax请求
 
 
html2js方式,用于和directive打包时的置入方式,手动将html放入templateCache  service中
angular.module('myApp', [])
  .run(function($templateCache) {
      $templateCache.put('templateId.html',
          'This is the content of the template'
      );
  });
posted @ 2015-12-12 15:50  Evans.wang  阅读(302)  评论(0编辑  收藏  举报