Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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 Select tag ng model返回一个未定义的值_Javascript_Html_Angularjs_Select_Angular Ngmodel - Fatal编程技术网

Javascript Select tag ng model返回一个未定义的值

Javascript Select tag ng model返回一个未定义的值,javascript,html,angularjs,select,angular-ngmodel,Javascript,Html,Angularjs,Select,Angular Ngmodel,我的html代码中有一个select标记,如下所示: <select ng-model="brandList" name="brandList" style="width:110px;" > <option value="" selected>---Please select---</option> <option ng-repeat="item in brandnameList | unique:'brandname'" value=

我的html代码中有一个select标记,如下所示:

<select ng-model="brandList" name="brandList"  style="width:110px;" >
    <option value="" selected>---Please select---</option>
    <option ng-repeat="item in brandnameList | unique:'brandname'" value="{{item.brandname}}" style="width:50px;"> {{item.brandname}}</option>

</select>
我有另一个函数需要选择标记上的选定值

    $scope.ExportmodalAdmin = function () {
            alert(  $scope.brandList )
    }

但是select的模型$scope.brandList返回一个未定义的值。我怎样才能解决这个问题?我需要将select标记中的值传递给函数。

希望您已经在控制器中定义了变量brandList

$scope.brandList = {};
另外,将您的ng repeat语句更改如下:

 <select ng-model="brandList" name="brandList" ng-options="item.brandname for item in brandnameList" style="width:110px;" ng-change="alertChange()" >
    <option value="" selected>---Please select---</option>
</select>

查看此处的plunker参考

希望您已经在控制器中定义了变量brandList

$scope.brandList = {};
另外,将您的ng repeat语句更改如下:

 <select ng-model="brandList" name="brandList" ng-options="item.brandname for item in brandnameList" style="width:110px;" ng-change="alertChange()" >
    <option value="" selected>---Please select---</option>
</select>


看看这里的plunker引用

post JSON示例,您从
adminService.getbrandnameList()
获得的代码是正确的,但缺少定义变量$scope.brandList={};在方法导出之前,请您将您的code@Chandru,我在方法exportmodalAdmin之前定义了变量$scope.brandList={},但它返回了从
adminService.getbrandnameList()获得的{Object Object}responsepost JSON示例
您的代码是正确的,但缺少定义变量$scope.brandList={};在方法导出之前,请您将您的code@Chandru,我在方法exportmodalAdmin之前定义了变量$scope.brandList={},但它返回{Object Object}响应我在控制器中定义了变量brandList,但它返回{Object}值。当我更改ng repeat语句时,下拉列表select上没有列出任何值。您可以发布getbrandnameList()函数的结果吗getbrandnameList()函数的结果如下[{“brandname”:“Aromatherapy Associates”},{“brandname”:“ST.Tropez”},{“brandname”:“Sampar”},{“brandname”:“Jack Black”},{“brandname”:“CeraVe”}]我已经更新了ng repeat部分。测试它,让我知道这些值仍然没有显示在下拉列表上。我在控制器中定义了变量brandList,但它返回{object | object}值。当我更改ng repeat语句时,下拉列表select上没有列出任何值。您可以发布getbrandnameList()函数的结果吗getbrandnameList()函数的结果如下[{“brandname”:“Aromatherapy Associates”},{“brandname”:“ST.Tropez”},{“brandname”:“Sampar”},{“brandname”:“Jack Black”},{“brandname”:“CeraVe”}]我已经更新了ng repeat部分。测试它,让我知道这些值仍然没有显示在下拉列表中