I am utilizing $resource to retrieve an array of objects. The method I am invoking is as follows:
fetchTeamResource(): ng.resource.IResourceClass<ITeamResource> {
return this.$resource("/api/Teams:teamId");
}
Below is how I am implementing it:
teamResource.query((data: app.domain.Team[]) => {
this.scope.teams = data;
});
While this setup is working flawlessly, my goal now is to pass a parameter and fetch an individual object instead of an array. The type of object I want to return is app.domain.Team, and the parameter I wish to use is teamName rather than teamId.
The backend api endpoint I plan to access has the following structure:
// GET: api/Teams/Chicago Bears
[HttpGet("api/Teams/{teamName}")]
public async Task<IActionResult> GetTeamByName([FromRoute] string teamName)
{....}
I'm hopeful that this question isn't too complex, I just need some guidance on the syntax required for $resource. Any assistance would be greatly appreciated!