在angularjs下拉列表中用ng-option调用动态数据

call dynamic data with ng-option in dropdownlist angularjs

本文关键字:调用 动态 数据 ng-option angularjs 下拉列表      更新时间:2023-09-26
<select ng-option="ubrandname as ubrandname.brand for brand in ubrandname track by ubrandname.brand" ng-model="ubrandname"></select>

这是我的下拉列表调用动态数据集从我的js文件

//brandnamebyid
            $http.get('/brandinfo.asmx/getbrandname', {
                params: {
                    log: log,
                    pm: pm,
                    id: $scope.updateparam.Id
                }
            })
            .then(function (response) {
                {
                    $scope.brandfunction = response.data.branddetails;
                    $scope.ubrandname = $scope.brandfunction[0];
                    console.log($scope.ubrandname);
                }
            });

我想我无法在我的下拉列表中写出正确的ng-option语法,有人能在这里帮助我吗?

您的ng-model和ng-option数据源似乎相同。

<select ng-option="brand as brand.brand for brand in brandfunction track by $index" ng-model="ubrandname"></select>

试试这个

<select ng-model="ubrandname">
    <option ng-repeat="brandname in brandfunction" value="{{brandname}}">{{brandname}}</option>
</select>