我有一个 AngularJS 的 $resource 定义如下:
var Menus = $resource('http://cafe.com/api/menus');
以及RESTful API。因此,当我对菜单
进行GET
请求时,会返回以下内容:
<cafe>
<collection href="http://cafe.com/api/menus" type="menus">
<template>
<data name="Name" prompt="Menu name" />
</template>
<items>
<item href="http://cafe.com/api/menus/1">
<link href="http://cafe.com/api/menus/1/ingredients" rel="ingredients" />
<data name="Name" prompt="Menu name">Morning</data>
</item>
<item href="http://cafe.com/api/menus/2">
<link href="http://cafe.com/api/menus/2/ingredients" rel="ingredients" />
<data name="Name" prompt="Menu name">Happy Hour</data>
</item>
</items>
</collection>
</cafe>
问题是,我如何删除菜单2?(假设它有自己的超媒体链接:
http://cafe.com/api/menus/2
)
href
来发送DELETE
请求。我支持,我在想每个项目是否都是一种“资源”对象类型?或者这对Angular来说要求太高了吗? - GregMenus
是什么(比如通过console.log
)? - Michelle Tilley