Explain $resource and its role in RESTful communication.

$resource is a service for interacting with RESTful APIs. It simplifies HTTP requests by creating a higher-level abstraction over $http.

const User = $resource('/api/users/:id');