ウェブAPIを介して入力されるドロップダウン(選択)があります。ウェブAPIの戻り値は、以下の構造を有する:AngularJSラベルと値を選択から取得する方法
{
"Id": 1,
"Description": "A description"
}
何が必要なのですが、私は私がデ対応するラベル(またはテキスト)と値を持つようにしたいオプションを選択したとき。これは私が持っているものです:オブジェクト全体だけではなく、それのIDを選択するために
(function (app) {
var requestCtrl = function ($scope, $http, requestTypeService) {
$scope.requestRows = [];
$scope.selectChange = function() {
$scope.RequestTypeID = $scope.requestTypeList.value;
$scope.RequestTypeDescription = $scope.requestTypeList.label;
}
requestTypeService.getAll().success(function (data) {
$scope.requestTypes = data;
});
$scope.addRequest = function() {
var requestRow = {
RequestTypeID: $scope.RequestTypeID, // Here I need the selected value
RequestTypeDescription: $scope.RequestTypeDescription, // Here I need the selected Description
EventColor: $scope.EventColor
};
$scope.requestRows.push(requestRow);
};
$scope.removePlanboardRequest = function (index) {
$scope.planboardRequests.splice(index, 1);
};
};
app.controller("PlanboardRequestCtrl", planboardRequestCtrl);
}(angular.module("planboardApp")));