直接上代码
<div class="control-group"> <label class="control-label">商品:</label> <div class="controls" ng-controller="goodsCtrl"> <select ng-model="selectGoods" ng-options="g.name for g in goods track by g.id" name="goods_id"></select> </div> </div>
其中 track by 后面的为option的value值, g.name用于显示选项名称。
<script type="text/javascript"> var app = angular.module('myApp',[]); app.controller('goodsCtrl',function($scope,$http) { $http({ method: 'GET',url: "{:U('orders/get_goods_list')}" }).then(function successCallback(response) { $scope.goods = response.data; // console.log(response.data); },function errorCallback(response) { // 请求失败执行代码 }); }); </script>