Issues with ngresource failing to properly filter data when calling an oData based Rest Controller

My web API controller is built with MongoDb as the backend.

    public class NodesRestController : ApiController
{
    private INodeService _nodeService;
    public NodesRestController(INodeService nodeService)
    {
        _nodeService = nodeService;
    }
    [EnableQuery()]
    public IQueryable<Node> Get()
    {
        return _nodeService.GetAllNodes().AsQueryable();
    }
    [EnableQuery()]
    public Node Get(Guid id)
    {
        return _nodeService.GetNodeById(id);
    }
}

Within my Angular application, the resource setup is as follows:

(function() {
'use strict';
var nodeServiceRoot = '/api/NodesRest/:id';

angular.module('common.service')
    .factory("nodeResource", ["$resource", "appSettings", nodeResource])

function nodeResource($resource, appSettings) {
    return $resource(appSettings.serverPath + nodeServiceRoot, {
        id: '@id'
    }, {
        "update": {
            method: "PUT"
        }
    });
}}());

The Nodes Collection contains multiple instances like the one below:

{
"_id" : LUUID("982d248a-ef2a-f94c-be93-96ff67ca1d3f"),
"Name" : "RTR1",
"IP" : "1.2.221.121",
"NodeGroup" : {
    "_id" : LUUID("36a38db3-830c-4a45-8b9c-63b16394f985"),
    "Name" : "Group One"
}}

I am attempting to retrieve nodes where NodeGroup.Name is "Group One", but I am getting back all nodes.

 var nodesInNodeGroup = nodeResource.query({ 'NodeGroup/Name': vm.CurrJob.NodeGroup.Name});
        nodesInNodeGroup.$promise.then(function (response) {
            nodesInNodeGroup = response;
        });

vm.CurrJob.NodeGroup.Name = 'Group One'

Any assistance would be appreciated.

Answer №1

The type of controller you are using is not compatible with OData.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to position a canvas solely on top of a centrally aligned image without covering the entire page?

Implementing angularjs in my application and incorporating fabric.js for canvas functionality. This is the HTML code I currently have: <div id="imageContainer" style=" width: 100%; height: 90vh; overflow: hidden"> <img id="imageId" align= ...

Consolidate all scripts into a single file with Asp.net MVC 5 bundling

On one of my razor pages, I have the following script section: @Scripts.Render("~/bundles/script1") @Scripts.Render("~/bundles/script2") @Scripts.Render("~/bundles/script3") The issue is that it renders three separate JavaScript files. Is there a way to ...

Is there a way to alter the color of a single row within a column in a jtable based on a specific condition?

statusOfPayment: { title: 'Status of Payment', width: '8%', options: {'Paid': 'Paid', 'Due': 'Due'}, create: false, ...

Having trouble fetching Realm Object by Primary Key in Swift 3 on iOS?

After upgrading my iOS Project to Swift 3 and iOS 10, I've encountered a strange issue with Realm. My goal is to update a set of Positions with Server Data. I want to update existing Positions if there is a newer version and add new Server Positions ...

What is the process for using dojo to load content?

As I work on creating a single-page website with the help of dojo, I refer to tutorials that explain how to utilize dojo/request for ajax requests. The process is straightforward - simply make a request, receive HTML content, and insert it into a designate ...

What methods can be used to accomplish this effect using CSS and/or Javascript?

Is there a way to achieve the desired effect using just a single line of text and CSS, instead of multiple heading tags and a CSS class like shown in the image below? Current Code : <h2 class="heading">Hi guys, How can i achieve this effect using j ...

Getting the value of "Page=?" from the href attribute in an HTML tag can be done using Selenium Webdriver and Java

I am looking to extract the value "page = ?" from a specific "href" tag in the HTML code below. I need this value for my Selenium WebDriver script so that my loop can iterate up to page 53. Can someone guide me on how to retrieve the "page =" value mentio ...

Is it possible in Angular to generate a module and component without including a CSS file in a single command?

Is it possible to generate a Module linked to a component without automatically creating a css file? For example, the default method I've been using involves: ng generate module name / ng generate component name This results in the typical componen ...

What is the best way to incorporate jQuery code into a specific page on a WordPress site?

I am struggling with adding jQuery to a single WordPress page for a script I have. Despite my efforts to find solutions, I find them difficult to grasp. <script> $(document).ready(function(e) { $('#checkboxtest').change(function(){ if( ...

Having trouble with obtaining real-time text translation using ngx translate/core in Angular 2 with Typescript

Issue : I am facing a challenge with fetching dynamic text from a JSON file and translating it using the translate.get() method in Angular2. this.translate.get('keyInJson').subscribe(res => { this.valueFromJson = res; /* cre ...

Utilizing a single controller in multiple locations within AngularJS

I am currently working on developing an Ionic application which includes screens with lists containing checkboxes and the option to select all items. My experience with AngularJS and Ionic is fairly limited. The "Select All" functionality works as intende ...

I am encountering difficulties with a nodejs query where I am unable to successfully include the "+" symbol as part of the query

Every time I submit a query for B+ or A+ {{URL}}/api/help/?bloodType=B+ it ends up showing as empty space, like this. Is there a way to properly pass the "+" sign in the query? Thanks. P.S: _ works fine. {"bloodType":"B "} ...

How to eliminate the ng-component tag from an Angular 8 table row template

I currently have a dynamic table component with 2 modes: Normal table - functioning properly Custom Row Template - encountering issues due to Angular adding the <ng-component> tag The logic within the TableComponent is not the main concern, it&apo ...

"Every time an Ajax call is successful, the 'else' clause in

When it comes to using Ajax for user login in the system, I encountered an issue where the Ajax success function would always run the else statement even if the server returned a true Boolean value. This meant that even when the login credentials were vali ...

Ways to retrieve a list of identifiers from arrays at both initial and subsequent levels

I'm currently dealing with a JSON/JavaScript structure that looks like this: { "comments": [ { "id": 1, "content": "lorem ipsum", "answers": [] }, { "id" ...

Combining jsTree with Treemodel for Enhanced Functionality

As someone new to Javascript, I'm looking for guidance on integrating jsTree on the front end with backend services in node.js. The backend utilizes the Treemodel library (http://jnuno.com/tree-model-js/) and includes additional functions like: funct ...

What advantages does JWT have over Firebase that make it the preferred choice?

In our authentication systems, we have the option to verify a user through Firebase or by their stored email in the database. Despite having these methods of verification, why do we incorporate JWT (json web token) into our processes? What distinct advan ...

The server has sent cookies headers, however, the browser did not store the cookies

I need assistance in understanding why browsers such as Chrome are not setting cookies, even though the Set-Cookie header is present in the Response Headers: Access-Control-Allow-Origin: * Connection: keep-alive Content-Length: 345 Content-Type: applicati ...

The class type "selectLabel" passed to the classes property in index.js:1 for Material-UI is not recognized in the ForwardRef(TablePagination) component

Just started using react and encountering a repetitive error in the console after adding this new component. Here is the full error message: Material-UI: The key selectLabel provided to the classes prop is not implemented in ForwardRef(TablePagination). ...

Having trouble making `overflow: hidden` work correctly when using padding on an element with `height:

Looking for some coding help here. My aim is to create a customized select menu with a sleek animation effect. I initially decided to set the default height to 0 and use overflow: hidden, then switch it to auto when .active class is applied. But, I'm ...