ng-model在angularjs中的ui-select中不起作用?

时间:2016-01-20 09:09:28

标签: javascript angularjs

ng-model="customer.selected"无效。它没有显示任何客户

<p>Selected: {{customer.selected}}</p>
     <div class="col-md-3">          
       <ui-select ng-model="customer.selected" theme="select2" class="input-md">
        <ui-select-match placeholder="Select a Customer">{{ $select.selected.name }}</ui-select-match>
          <ui-select-choices repeat="customer in customers | propsFilter: {name: $select.search}">
           <div ng-bind-html="customer.name | highlight: $select.search"></div>
          </ui-select-choices>
        </ui-select>
    </div>

1 个答案:

答案 0 :(得分:1)

在控制器中将模型值设置为默认值,然后它应该可以正常工作。

$scope.customer = {};
$scope.customer.selected = {};