AngularJS HTML模板/片段管理 [英] AngularJS HTML template/snippet management

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

问题描述

我是骨干来一个角+小白+木偶要求。

I'm an Angular noob coming from Backbone+Marionette+Require.

如果你有一堆意见和一堆指示每个都有自己的HTML你在哪里把所有的HTML片段的应用程序?大部分时间我看到的例子将它们保存内联,在自己的脚本标记,或异步加载。有一件事我喜欢RequireJS是,模板可以生活在自己的文件,但可以被编译成生产的主要JS文件。我想有一个咕噜任务或类似的东西?也许有,在建造时间从单个文件需要HTML并将它们嵌入单个脚本标签合并HTML文件?

If you have an app with a bunch of views and a bunch of directives each with their own HTML where are you putting all the HTML snippets? Most of the examples I see are storing them either inline, in their own script tags, or loaded asynchronously. One thing I love about RequireJS is that templates can live in their own files but can be compiled into the main JS file for production. I assume there's a grunt task or something similar? Maybe one that takes HTML from individual files and embeds them into individual script tags in a consolidated HTML file at build time?

感谢。

推荐答案

有的确是一个咕噜任务来完成!最初由href=\"http://angular-ui.github.com/bootstrap\" rel=\"nofollow\">角UI引导队 html2js 任务,将你的模板并编译它们放入一个JavaScript文件(采用了棱角分明的 $ templateCache ),可以与你的脚本的其余部分连接起来形成一个单一的有效载荷。

There is indeed a Grunt task to do this! Originally created by the Angular-UI Bootstrap team, the html2js task will take your templates and compile them into a JavaScript file (using angular's $templateCache) that can be concatenated with the rest of your scripts to form a single payload.

我还没有公布它尚未,因为我仍然在增加的文档,但看一看 ngBoilerplate ,一个AngularJS Kickstarter的项目,看到它在上下文中。

I haven't released it yet as I am still adding documentation, but take a look at ngBoilerplate, an AngularJS project kickstarter, to see it in context.

更新(2013年2月28日):我只是做了ngBoilerplate的释放。你可以在这里查看官方网站: http://bit.ly/ngBoilerplate

Update (28 Feb 2013): I just made a release of ngBoilerplate. You can check out the official site here: http://bit.ly/ngBoilerplate.

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

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