码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-12-12 16:52:48      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

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‘
      );
  });

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

标签:

原文地址:http://www.cnblogs.com/windSamW/p/5041354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!