Grails Asset-pipeline 不加载角度部分模板 [英] Grails Asset-pipeline does not load angular partial templates

查看:17
本文介绍了Grails Asset-pipeline 不加载角度部分模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 angular-ui-bootstrap 与 Grails 2.3.x asset-pipeline:1.6.1 插件一起使用.组件之一 - alert.js 正在尝试加载/template/alert/alert.html 但这解析为 404.

我尝试包含 grails.assets.includes=[*/.html],但没有帮助.

有什么解决方法吗?无论如何让资产管道包含部分模板?

解决方案

感谢您的 关于 AngularJS 和 Grails 的很棒的博客,它让我开始了这个话题.

关于部分,我认为 assets 目录不是放置它们的正确位置,因为它们在生产模式下被连接和缩小.

相反,我使用 GSP 模板作为 AngularJS 部分.例如,我有

views/partials/login.gsp

Hello World!

conf/UrlMappings.groovy

静态映射 = {...'/partials/login'(视图:'/partials/_login')}

grails-app/assets/javascript/

<代码>...templateUrl: 'partials/login',...

优点:您甚至可以在部分中使用 scriptlets 和 taglibs.

直接使用 GSP 的替代方法是 James Kleeh 在此线程中的方法.

最好的问候,比约恩

Im using angular-ui-bootstrap with Grails 2.3.x asset-pipeline:1.6.1 plugin. One of the components - alert.js is attempting to load /template/alert/alert.html but this resolves to 404.

I tried including grails.assets.includes=[*/.html], did not help.

Any workaround for this? Anyway to let asset-pipeline include partial templates?

解决方案

thanks for your great blog about AngularJS and Grails, which jumpstarted me on this topic.

Regarding partials, I assume the assets directory is not the right place to put them, because they get concatenated and minified in production mode.

Instead, I use GSP templates as AngularJS partials. For example, I have

views/partials/login.gsp

<div>Hello World!</div>

conf/UrlMappings.groovy

static mappings = {
  ...
  '/partials/login'(view:'/partials/_login')
}

grails-app/assets/javascript/

...
templateUrl: 'partials/login',
...

Advantage: You may even use script lets and taglibs in the partials.

An alternative to using GSP directly would be James Kleeh's approach in this thread.

Best regards, Björn

这篇关于Grails Asset-pipeline 不加载角度部分模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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