相关疑难解决方法(0)

从类型中选择更新模型

请考虑我的html文件正文中的以下内容:

<html>
...
<body>
...
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<input type="text" ng-model="selected" typeahead="name as entry.name for entry in entries | filter:{name: $viewValue} | limitTo:8" 
                 typeahead-on-select='onSelect($item, $model, $label)'
                 class="form-control">

{{selection_made}}
</div>
<body>
</html>
Run Code Online (Sandbox Code Playgroud)

在哪里entries填充其他地方.然后在控制器中:

angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl', function($scope, $http) {
        ...
        $scope.onSelect = function ($item, $model, $label) {
                $scope.$selection_made = $item;
        };
...
});
Run Code Online (Sandbox Code Playgroud)

我有自动完成工作,但选择回调似乎不能正常工作.我希望{{selection_made}}显示所选的任何内容,而是{{selection_made}}呈现文字文本.为什么?我错过了什么?

注意:我用这个答案作为参考.

angularjs angular-ui-bootstrap

6
推荐指数
0
解决办法
2万
查看次数

标签 统计

angular-ui-bootstrap ×1

angularjs ×1