ui-select工作不正常

时间:2016-09-01 07:37:39

标签: angularjs ui-select

我使用 ui-select 进行自动完成,如果我从列表中选择选项但是当我选择选项时它无法正常工作来自匹配的查询列表。

<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'},
];

请帮助我,提前致谢。

1 个答案:

答案 0 :(得分:0)

这里的问题是没有国家/地区数组class DemoController extends MvcPublicController { public function hello(){ print_r($this->params); die(); } } 来存储正在选择的值。如果你可以启动一个空对象,它将正常工作。并且还鼓励使用$ scope而不是使用您正在使用的方法。