元素方法

  • get([queryParams, headers]): Gets the element. Query params and headers are optionals
  • getList(subElement, [queryParams, headers]): 得到一个嵌套资源. subElement is mandatory. It's a string with the name of the nested resource (and URL). For example buildings
  • put([queryParams, headers]): Does a put to the current element
  • post(subElement, elementToPost, [queryParams, headers]): Does a POST and creates a subElement. Subelement is mandatory and is the nested resource. Element to post is the object to post to the server
  • remove([queryParams, headers]): Does a DELETE. By default, remove sends a request with an empty object, which may cause problems with some servers or browsers. This shows how to configure RESTangular to have no payload.
  • head([queryParams, headers]): Does a HEAD
  • trace([queryParams, headers]): Does a TRACE
  • options([queryParams, headers]): Does a OPTIONS
  • patch(object, [queryParams, headers]): Does a PATCH
  • one(route, id): Used for RequestLess connections and URL Building. See section below.
  • all(route): Used for RequestLess connections and URL Building. See section below.
  • several(route, ids*): Used for RequestLess connections and URL Building. See section below.
  • oneUrl(route, url): This will create a new Restangular object that is just a pointer to one element with the specified URL.
  • allUrl(route, url): This creates a Restangular object that is just a pointer to a list at the specified URL.
  • getRestangularUrl(): Gets the URL of the current object.
  • getRequestedUrl(): Gets the real URL the current object was requested with (incl. GET parameters). Will equal getRestangularUrl() when no parameters were used, before calling get(), or when using on a nested child.
  • getParentList(): Gets the parent list to which it belongs (if any)
  • clone(): Copies the element. It's an alias to calling Restangular.copy(elem).
  • plain(): Returns the plain element received from the server without any of the enhanced methods from Restangular. It's an alias to calling Restangular.stripRestangular(elem)
  • withHttpConfig(httpConfig): It lets you set a configuration for $http only for the next call. Check the Local Config HTTP section for an example.
  • save: Calling save will determine whether to do PUT or POST accordingly