javascript - Angular Controller accessing individual items -


i working on angular app (rails backend, separate repo backend) many many relation between items , outfits, outfit_items join table model between them. in angular show controller outfits, trying write delete function remove items outfit.

    this.destroy = function(){       self.outfit = outfitfactory.get({id: $stateparams.id}, function(){         self.outfit_item = outfititemfactory.query({id: $stateparams.id}, function(){           self.outfit_item.$remove_from_outfit({id: self.items.id, outfit_id: self.outfit_id});     })   }) } 

when console outfit_item shows of items outfit. tried using .get instead got angular error error: $resource:badcfg response not match configured parameter. how else can access individual item here can run remove function on that?

also, have function defined in rails controller outfits follows:

def remove_from_outfit   @outfit = outfit.find(params[:outfit_id])   @outfit_item = @outfit.outfit_item   @outfit_item.destroy   render json: {message: "success"}, status: :ok end 


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -