Angularjs 如何使用带值和文本的“角度ui选择”选定项
我有一份已加载到的国家列表 代码的详细信息如下所示Angularjs 如何使用带值和文本的“角度ui选择”选定项,angularjs,angular-ui,ui-select2,ui-select,Angularjs,Angular Ui,Ui Select2,Ui Select,我有一份已加载到的国家列表 代码的详细信息如下所示 %ui-select{'ng-model' => 'item.country', 'append-to-body' => 'true', 'search-enable' => 'true', 'them' => 'bootstrap'} %ui-select-match{'allow-clear' => 'true', placeholder: :'select country'}
%ui-select{'ng-model' => 'item.country', 'append-to-body' => 'true', 'search-enable' => 'true', 'them' => 'bootstrap'}
%ui-select-match{'allow-clear' => 'true', placeholder: :'select country'}{{$select.selected.name}}
%ui-select-choices{'repeat' => "country.code as country in countries | filter:$select.search"}
%span {{country.name}}
每个对象国家都有两个属性:代码和名称
当我选择一个项目时,该值和显示的文本总是名称
我希望在选择项目时,值为“代码”,显示的文本为“名称”。
%ui选择选项元素可以变成
像这样:
%option{'ng-repeat' => "country in countries", 'value' => '{{country.code}}', 'text' => '{{country.name}}'}
如何解决此问题?试试看
country.code as country.name for countries in countries如果我们使用表达式country.code as country.name for countries in countries in repeat会出现错误。此表达式适用于ng选项