嗨,我已将以前用于在 api 中编辑记录的功能转换为以下资源:
app.factory("Wine", function($resource){
return $resource("http://greatwines.8000.com/wines:id", {
//id as a variable
id: "@id"
},
{
update: {
method: "PUT"
}
});
});
我现在想通过触发带有“葡萄酒”记录的表单来使用它,以便在每种葡萄酒的葡萄酒 ng-repeat 中使用以下 CTA 进行编辑:
<a href="#/wines/{{wine.id}}" class="btn btn-default">Edit Wine</a>
在我的控制器中,我传递了“Wine”资源:
app.controller("editWineCtrl", function ($scope, $http, $routeParams, Wine, $location){
Wine.get({ id: $routeParams.id }, function(wine){
$scope.wine = wine;
});
...
但是,尽管表单 URL 返回了 ID:
http://greatwines.8000.com/#/wines/1323
没有任何字段,即:
div class="margin-top-20">
<input type="text" class="form-control" ng-model="wine.year" />
</div>
<div class="bold margin-top-20">
Grapes
</div>
<div class="margin-top-20">
<input type="text" class="form-control" ng-model="wine.grapes" />
</div>
正在被填充。我是否以正确的方式使用资源?