AngularJS模块中的html模板 [英] html templates in AngularJS modules

查看:47
本文介绍了AngularJS模块中的html模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在AngularJS模块中包含html模板,而不必将它们作为字符串放入js代码的templateCache中?

Is there a way to include html templates in AngularJS modules without putting them as strings into js code into the templateCache?

推荐答案

我们完成此操作的方法是将html模板编写为独立的html文件,然后使用

The way we've accomplished this is to write our html templates as standalone html files, then use a grunt task to crunch them into strings (handles all the escaping etc) and inject them into the template cache. best of both worlds, as the developers can work on individual HTML files all under source control, but we drastically reduce roundtrips to the server to pull the templates down to the app at runtime. (At the cost of up-front loading)

这篇关于AngularJS模块中的html模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆