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 theapiService.get(../../api/Firm/