【发布时间】:2016-11-15 05:04:35
【问题描述】:
编辑:代码没问题,问题是
materializeselect,不适用于动态角度元素,使用class browser-default而不是input-field,不要初始化使用 jquery。
您好,我正在尝试在带有角度的 select 标记中显示数据
我读了很多,但我无法解决这个问题。正如您所看到的,测试代码有效,但函数无效。需要帮忙。谢谢。
这是 PHP 端点返回的 JSON:
{
"records":[
{
"numero":"312312"
},
{
"numero":"31221111"
},
{
"numero":"311241"
},
{
"numero":"112441"
},
{
"numero":"11312"
},
{
"numero":"131"
}
]
}
控制器:
app.controller('chequeoCtrl', function($scope, $http) {
//with this function do not work
$scope.leerNumero = function() {
$http.get("objetos/autoelevador/leer_numero.php").success(function(response) {
$scope.data = response.records;
console.log($scope.data);
});
};
$scope.leerNumero();
// with this array works, just for test!!
/*$scope.names = [{"name":"pepe"},{"name":"pepe2"}];
console.log($scope.nombres); */
})
我的select标签:
<select ng-model="autoelev" ng-options="item.numero as item.numero for item in data">
<option value="" disabled selected>Seleccionar autoelevador</option>
</select>
【问题讨论】:
标签: angularjs json select options