我使用ui-为自动完成选择,如果我从列表中选择选项,但当我从匹配的查询列表中选择选项时,它是工作的。
<ui-select ng-model="mycontroller.country" name="country">
<ui-select-match placeholder="country">
<span data-ng-bind="$select.selected.country_id"></span>
</ui-select-match>
<ui-select-choices repeat="country in mycontroller.countries | filter: $select.search | orderBy: 'country_id' | unique: 'country_id'">
<span data-ng-bind="country.country_name"></span>
</ui-select-choices>
</ui-select>这是我的js
var app = angular.module('app', ['ngSanitize', 'ui.select']);
angular.module('app').controller('mycontroller', ['$scope', function ($scope){
var self= this;
self.countries = [
{id: 1, name: 'india'},
{id: 2, name: 'spain'},
{id: 3, name: 'malasiya'},
{id: 4, name: 'ithali'},
{id: 5, name: 'usa'},
];请帮我,谢谢。
发布于 2016-09-16 13:20:25
这里的问题是,没有用于存储所选值的国家数组$scope.country= ""。如果您可以启动一个空对象,它就会正常工作。同时也鼓励使用$scope,而不是使用您正在使用的方法。
https://stackoverflow.com/questions/39265463
复制相似问题