如何将 angular js 集成到 grails 2.3.4 中? [英] How to integrate angular js into grails 2.3.4?
问题描述
我在 grails 2.3.4
上运行,但关于在我的下一个应用程序中集成 angularjs.
I am running on grails 2.3.4
and though about integrating angularjs in my next application.
我认为服务器端的最佳方法是在域和控制器类中使用 grails REST
集成.
I think the best way from the server side is to use grails REST
integration in the domain and controller classes.
但是在这里我被卡住了.
However here I am stuck.
如何让 grails 与 angularjs 通信?(通过 index.gsp
?,如果是这样,如何集成它?)什么是好的架构?
How to get grails to communicate with angularjs?(over the index.gsp
?, If so how to integrate it?) What would be a good architecture?
非常感谢您的回答!!!
I really appreciate your answers!!!
PS.:我知道有一个 grails angular js 插件.但是我确实看到了使用它的任何理由!
PS.: I know that there is a grails angular js plugin. However I do see any reason for using that!
推荐答案
我们选择不使用 angular-js 资源插件,而是自己使用.只是为了更灵活地更新时间和内容等.
We chose to not to use angular-js resources plugin, but instead use on our own. Just for more flexibility on when and what to update etc.
只需将 angularjs 文件放在/js/lib 文件夹中.创建资源包文件.(我们有 grails-app/conf/AngularResources.groovy 文件)并在那里声明你的 angular js 资源包,如下所示.我们在 AngularResources.groovy 中声明了我们所有的 Angular 资源,例如控制器/服务/应用程序/指令
Just put the angularjs files inside /js/lib folder. Create a resource bundle file. (we have grails-app/conf/AngularResources.groovy file) and declare your angular js resource bundles there as shown below. We declared all our angular resources, like, controllers/services/apps/directives inside AngularResources.groovy
modules = {
'angular' {
resource url:"js/lib/angular/angular.min.js", nominify:true
resource url:"js/lib/angular/angular-resource.min.js", nominify:true
}
}
需要屏幕上要使用的模块.
Require the module on the screen where you want to use it.
这篇关于如何将 angular js 集成到 grails 2.3.4 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!