Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS如何从ng选项中选择值_Javascript_C#_Angularjs - Fatal编程技术网

Javascript AngularJS如何从ng选项中选择值

Javascript AngularJS如何从ng选项中选择值,javascript,c#,angularjs,Javascript,C#,Angularjs,我在选择ng选项中插入值,我想在特定月份的下拉列表中选择。 这是返回所有12个月的arrray,所以如何从下拉列表中仅获取所选月份 脚本: $scope.Month = ['Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; $scope.selectmonth = $scope.Month; $scope.SaveReport = function () {

我在选择ng选项中插入值,我想在特定月份的下拉列表中选择。 这是返回所有12个月的arrray,所以如何从下拉列表中仅获取所选月份

脚本:

$scope.Month = ['Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
 $scope.selectmonth = $scope.Month;

 $scope.SaveReport = function () {

    PrintReportRepository.save(
            {
             SelectMonth: $scope.selectmonth,
             },
html

 <select class="form-control" ng-model="selectmonth" ng-options ="months as months for months in Month">{{months}}</select>
{{months}

要设置所选的第一项,请使用
$scope.selectmonth=$scope.Month[0]
,通过设置
$scope.selectmonth=$scope.Month
U将整个阵列设置为一个模型使用此代码:请参阅

控制器:

$scope.Month = ['Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
 $scope.SaveReport = function () {
    console.log('SelectMonth', $scope.selectmonth);
 }
html:


<select class="form-control" ng-model="selectmonth" ng-options ="months as months for months in Month" ng-change="SaveReport()"></select>