angular - 我在哪里可以在 grails 服务器角度客户端上添加代码
问题描述
我按照本指南修改了角度侧。我以前只使用过 grails,现在我遇到了问题。如何将函数添加到 post 方法?或者,我可以在服务器端的何处以及如何在注册新客户时添加自动发送电子邮件功能?
从我之前只使用 grails 的工作来看,这是使用控制器和修改save()
方法制作的,但现在我找不到该方法或客户控制器的位置。
如果有人可以帮助我,我将不胜感激。另外,我不明白请求如何与角度一起工作。
解决方案
How can I add a function to the post method?
The post
method is a function. In general they are referred to as methods in Groovy, but in this context those names mean the same thing. The language doesn't allow you to add a method to a method (or a function to a function, or any combo of those).
Or where and how in the server side can I add an automatically send email funtion when register a new customer?
That depends on a number of factors in your app but assuming your app is using GORM, you could have an asynchronous listener respond to PreInsertEvent
(or similar) and in the listener initiate the sending of an email. If you are not using GORM, you could put the mail sending code in a Grails Service and call that service method from your controller action that supports registering a new customer.
推荐阅读
- android - 我可以从 Android/iOS 设备每 5 秒广播一次蓝牙低功耗 20 KB 数据吗?
- angular - 来自组件的 NGRX 顺序调用操作
- javascript - 异步回调返回值
- python-3.x - 如何访问给定的 xpath 结果?
- c# - 使用列表中的列表的 Lambda 方法查询语法
- kotlin - 如何使用从 application.properties 中获取的值初始化伴随对象属性?
- asp.net-core-3.1 - 如何从 Startup.CS 查询数据库
- android - 如何使用 ktor 库和 kotlin 下载 .apk?
- javascript - 循环对象对象并在找到特定值时中断
- python - 为什么这个递归函数只在类中实例化变量时才起作用?