选择无法显示名称的选项 - angularJS

时间:2015-04-22 11:23:14

标签: html angularjs html-select

我有select我正在填写controller。或者至少应该这样做。

我一直在尝试这个

<select class="form-control selectWidth" 
    required 
    ng-model="template.type" 
    ng-init="template.type = template.type || types[0]"
    ng-options="type.name as type.name for type in types">

    <option style="display:none" value="" disabled>select a type</option>
</select>

来自我的控制器的$scope.types

$scope.types = [
    { title:'cities', type:'city', templates: []},
    { title:'buildings', type:'building', templates: []}
];

select会添加项目,但名称不会显示。

1 个答案:

答案 0 :(得分:1)

我想你要改变

type.name as type.name for type in type

type.title as type.title for type in type

或者

type.type as type.type for type in type

取决于您要显示的内容