0
我正在使用angularjs(ng-options)创建一个选择下拉列表,它使用php中的sql查询填充以将我的选项列表作为json返回。在angularjs下拉列表中删除未定义的值
这对于下拉菜单很适用。我现在试图添加使用不同查询的第二个下拉菜单。我使用php array_merge合并2个查询结果数组,然后json_encode合并数组。
两个下拉列表填充,但两者有很多不必要的不确定值,我不知道why..The未定义的值不存在时,我只能回到1个奇数组(而不是合并两个)
我在json本身中没有任何未定义的结果对象。只有在选择下拉
getInfo();
function getInfo(){
// Sending request to EmpDetails.php files
$http.post('databaseFiles/options.php').success(function(result){
// Stored the returned data into scope
$scope.options = result;
console.log(result);
});
}
<select class="form-control" ng-model="selectedDepartment"
ng-options="option.id as option.department for option in options ">
<option value="">Select Department</option>
</select>
属性之前值'''$ scope.options''',检查是否'''typeof result.data ==='undefined''''' – Zooly
您发布的代码片段将不会运行,因为此错误消息:“未捕获的ReferenceError:$ http未定义”您可以发布$ scope.options的内容吗? –