【发布时间】:2013-02-26 21:47:07
【问题描述】:
当页面加载时,资源会抛出 404,因为 $resource 为 :city_id 读取 nil。我从 angularjs 开始,所以任何澄清都值得赞赏。
表单条目无法持久化,因为此 $resource 还用于 PUT 模型中的条目。
app = angular.module("CityAngular", ["ngResource"])
app.factory "Seal", ["$resource", ($resource) ->
$resource("/cities/:city_id/seals/:id", {city_id: "@city_id", id: "@id"}, {update: {method: "PUT"}})
]
@SealCtrl = ["$scope", "Seal", ($scope, Seal) ->
$scope.seals = Seal.query()
$scope.addSeal = ->
seal = Seal.save($scope.newSeal)
$scope.seals.push(seal)
$scope.newSeal = {}
]
【问题讨论】:
标签: ruby-on-rails coffeescript angularjs angular-resource