【发布时间】:2015-05-19 13:57:01
【问题描述】:
我正在尝试将对象添加到 Grails 中的 JSON 列表。这是我的 Angular 代码: http://pastebin.com/4ypijUMD
还有我的 Grails 控制器: http://pastebin.com/skTtVtxv
据我了解,我的 angularJS 脚本应该发送一个请求以使用列表中最新成员的信息访问添加控制器。
那么 add 函数应该根据从 angular 脚本和 ta-da 传递到控制器的参数创建一个新的 JSON 对象。
但是,什么都没有创建,当我尝试更新我的时,我只是得到空对象
list with my update controller:
def saveList() {
def newItem = Item.findById(request.JSON.id)
newItem.name = request.JSON.name
newItem.type = request.JSON.type
newItem.priority = request.JSON.priority
newItem.completed = request.JSON.completed
newItem.save(flush: true)
render newItem as JSON
}
【问题讨论】:
标签: javascript json angularjs grails