JamTay317
JamTay317

Reputation: 1017

Angularjs API call to different action

I am pretty new to AngularJs, so forgive me for not knowing this. What I am trying to do: I am trying to call an api with a different method name. I have seen a lot about $resource, however i don't understand it.

So the method I am trying to call:

        [Route("api/regions/{id?}"), Authorize]    
        [HttpGet]
        public IEnumerable<Region> GetRegionsByStateId(Guid id)
        {
            var regions = _repository.Get();
            return regions.Where(x => x.StateId == id);
        }

I have tried $http.get('api/regions/'+stateId) which doesnt work, can someone either explain the $resource a little better to me ot tell me why this doesnt work.

Upvotes: 0

Views: 26

Answers (1)

Suyog
Suyog

Reputation: 181

try this

    [Route("api/regions/{id}"), Authorize]
    [HttpGet]
    public IEnumerable<Region> GetRegionsByStateId(Guid id)
    {
        var regions = _repository.Get();
        return regions.Where(x => x.StateId == id);
    }

Upvotes: 1

Related Questions