大佬教程收集整理的这篇文章主要介绍了有使用AngularJS路由预加载模板的方法吗?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这样的东西是理想的:@H_673_2@
$routeProvider .when('/p1',{ controller: controller1,templateUrl: 'Template1.html',preload: true })@H_301_5@
例如,从文档:@H_673_2@
var myApp = angular.module('myApp',[]); myApp.run(function($templateCachE) { $templateCache.put('templatEID.html','This is the content of the template'); });
甚至有一个grunt任务从html文件预生成一个javascript模块:grunt-angular-templates@H_673_2@
另一种方式,也许不太灵活,是使用内联模板,例如,在index.html中有一个类似这样的脚本标签:@H_673_2@
<script type="text/ng-template" id="templates/Template1.html">template content</script>
意味着模板可以在后面以与路由配置中的真实url相同的方式进行编址(templateUrl:’templates / Template1.html’)@H_673_2@ @H_301_5@
以上是大佬教程为你收集整理的有使用AngularJS路由预加载模板的方法吗?全部内容,希望文章能够帮你解决有使用AngularJS路由预加载模板的方法吗?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。