Closed. This question is not reproducible or was caused by typos。它当前不接受答案。
                        
                    
                
            
        
            
        
                
                    
                
            
                
                    想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                
                    2年前关闭。
            
        

    

尽管通过数组填充了值,但为什么值未定义。
尽管存在这些值,但为什么它显示未定义。



var app= angular.module('myApp',[]);
app.controller('myController',function($scope){
  $scope.city=['Odisha','Hyderabad'];
});

div{
  text-align: center;
}

<htmL>
  <head>
    <title>Movie Ticket Booking</title>
  </head>

  <body ng-app="myApp" ng-controller="myController">
    <div>
      Choose City:<select ng-model="cities" ng-change="changeCity()" ng-options="items for item in city"></select>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
  </body>
  </html>

最佳答案

您需要使用item而不是items



var app= angular.module('myApp',[]);
app.controller('myController',function($scope){
  $scope.city=['Odisha','Hyderabad'];
});

div{
  text-align: center;
}

<htmL>
  <head>
    <title>Movie Ticket Booking</title>
  </head>

  <body ng-app="myApp" ng-controller="myController">
    <div>
      Choose City:<select ng-model="cities" ng-change="changeCity()" ng-options="item for item in city track by item"></select>
    </div>
    <div>{{cities}}</div>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
  </body>
  </html>

09-25 19:54