Response from the controller upon choosing a value from the selection dropdown

Scenario:

In this scenario, there are two tables in consideration:

Firm table : ID (string), Firm(string)

Firms table: FirmID(string FK), Name(string)

The goal is to select a value from the Firm table, pass it to the controller as Firm, and then execute a query based on the received value from Firms table.

View:

<select ng-change="filtro(selected)" ng-init="Banks= Firm[0]" ng-model="selected" ng-options="item.Name for item in Firms">
  </select><br/>

JS:

 function GetFirm() {
            apiService.get("../../api/Firms/", null,
                function (res) {
                    $scope.Firm = res.data;
                    $scope.selected = $scope.Firms[0];
                }, errorFirm);
        }

Controller: Retrieving selected value

public HttpResponseMessage GetFirm(HttpRequestMessage request, string firm)
        {
                //some code here
        }

How can the selected value be passed into string firm? I believe it involves another JavaScript function, but I'm quite confused about that part.

Note: The method where string firm needs to be passed is within the apiService.get(../../api/Firm/

Answer №1

To retrieve the selected value, simply utilize ng-change,

Within your controller:

$scope.filter = function(selected){
    apiService.fetch(../../api/Status/+selected.Name ;
}

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

Easily manipulate textboxes by dynamically adding or deleting them and then sending the data to a

Can you provide a simple example of how to dynamically add and remove textboxes and then display the results? I envision it like this: [Empty Textbox][Add button] When 'Value1' is entered into the textbox and 'add' is clicked, it s ...

Error: Firebase has encountered a network AuthError, which could be due to a timeout, interrupted connection, or an unreachable host. Please try again later. (auth/network-request-failed

I have set up my Angular app to utilize Firebase's emulators by following the instructions provided in this helpful guide. In my app.module.ts, I made the necessary configurations as shown below: import { USE_EMULATOR as USE_AUTH_EMULATOR } from &apos ...

Inability of AngularJS and Google Maps API V3 to Geocode an Address Iteratively

I'm currently attempting to geocode markers for each location in an AngularJS scope accessible through $scope.locations Unfortunately, I keep encountering the error message TypeError: Cannot call method 'geocode' of undefined To address th ...

Eliminate all elements marked with a particular class when the user clicks outside of a

I am currently building upon a project that I previously started here. Essentially, what I'm doing is dynamically generating tooltip popups that appear next to a link when it is clicked. However, I now need these tooltips to close when any click even ...

Steps for upgrading the Angular version within the Ionic Framework

I'm experiencing some challenges with Angular filters. I've been told that the issue may be due to me not using angular 1.3.8 or a higher version. To check my current version, I ran angular.version in the console and it returned: Object {full: "1 ...

I am experiencing issues with datejs not functioning properly on Chrome browser

I encountered an issue while trying to use datejs in Chrome as it doesn't seem to work properly. Is there a workaround for this problem if I still want to utilize this library? If not, can anyone recommend an excellent alternative date library that ...

What is the best way to determine in component.html whether the column type is equal to 1 to show the label text "Active,"

Having trouble checking the value of an object named ReportControl. If the column type is 1, display the label "active"; otherwise, display the label "not active" on reportcomponent.html. The data for the ReportControl object is as follows: {"reportId": ...

Refreshing Knockout Model

Recently, I started learning Knockout and I'm facing a challenge with updating my ViewModel after an ajax call. Below is the current setup: LoanDeductions.js var deductionLine = function (deductionID, deductionName, amount) { self = this; ...

What steps should I follow to create a Lunr search functionality for Markdown MD files?

Currently, I am in search of a suitable lunr search implementation for my MD (Markdown) documents spread throughout my React/NextJS website. Our website contains a plethora of Markdown docs within both blog and regular "docs" sections, necessitating a robu ...

Display the retrieved information from MongoDB onto a jade template

Upon checking the console, I see output similar to this: [ { __v: 0, city: 'on1', address: '111', first: 'user', last: 'one', chart: 'char1', doctor: 'doc1', _id: 5698a803d98f05482ba48a4b }, { __ ...

Sending data from an AngularJS frontend to a Laravel backend using an HTTP

I've been researching, but I can't seem to make sense of anything. I'm new to Laravel and I want to use it as a backend for my AngularJS project. Since I have experience with Angular, here is the controller function where I make an HTTP call ...

ngGrid: cellTemplate unable to capture user inputs

I'm currently using ngGrid to collect data. I'm facing difficulty in updating $scope.myData on submission after entering inputs in a CellTemplate within the age columns. Query: How can I capture data with cellTemplates and obtain an updated $sc ...

What are some ways to implement smooth scrolling when a navigation link is clicked?

I have a total of 3 links in my navigation bar and every time they are clicked, I want the page to smoothly scroll down to their designated section on the webpage. Although I have already set up the anchors, I lack experience in scripting to create the smo ...

Troubleshooting the CrossDomain problem while attempting to make an Ajax request to a Web

In my solution, I have two main projects: WebApi and WebPage. The Web API project returns data using the URL http://localhost:63983/api/values. On the other hand, the main web project uses a different port at http://localhost:63421/#/. When I run my Web P ...

Essential Understanding of HTML Query Strings Required

As a newcomer to the world of web design, I have taken on what seems like a challenging task for me: creating a webpage that can send a query string to the German Railway website (bahn.de) with the parameters I input. My question now is whether there is a ...

Utilizing Angular in combination with Express-Handlebars for a Node.js project

I'm currently working on a node.js application with Express and express handlebars as the templating framework. Recently, I've been delving into Angular and trying to integrate it into my node.js app. However, I've encountered an issue wher ...

Issue with ng-hide logic malfunctioning

I am currently developing an Ionic application and encountering some issues with the ng-hide directive. My goal is to display or hide a button based on whether the user has completed registration. The button in question: <button class="button button-c ...

encasing a snippet of code within a customized hyperlink

Here's the following "embed code" for an Instagram photo featuring Kim Kardashian. I'm curious - how can one encapsulate this embed code within an <a> tag (or another tag) so that clicking on the image will redirect to www.google.com? < ...

``Is there a way to access the $attrs data of child DOM elements from within a controller?

Imagine having a controller and multiple children DOMs each with their unique data attributes. <!DOCTYPE html> <html ng-app="plunker"> <head> <meta charset="utf-8" /> <title>AngularJS Plunker</title> < ...

Issue with Cross-Origin Resource Sharing (CORS) specifically affecting AngularJS POST requests in Firefox

I am encountering a problem specifically in FireFox when attempting to make a cross-origin request within an Ionic application (utilizing AngularJS). The Javascript application is sending a $http.post() to a Laravel 5.1 API, and I am receiving the followin ...