搜索某个人时是否可以显示与该人有关的所有资料。并且还必须选择多个人。

这是我的示例代码.....

<!doctype html>
<html ng-app="plunker">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
    <script src="http://angular-ui.github.com/bootstrap/ui-bootstrap-tpls-0.2.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
  </head>
  <body>

<div class='container-fluid' ng-controller="TypeaheadCtrl">
    <input type="text" ng-model="selectedStuff" typeahead="stuff as stuff.desc for stuff in stuffs | filter:{name: $viewValue, desc: $viewValue}"/>
    <span>{{selectedStuff.name}}</span>
    <span>{{selectedStuff.desc}}</span>
</div>
  </body>
</html>


和js代码.....

angular.module('plunker', ['ui.bootstrap']);
function TypeaheadCtrl($scope) {

  $scope.stuffs= [
                {
                 "name":"thing1",
                 "desc":"this is the first thing",
                 "title": "this is the first title"
                },
                {
                 "name":"thing2",
                 "desc":"this is the second thing",
                 "title": "this is the second title"
                }
               ]
}


在这里,当我搜索时,它仅显示名称或desc或title,但是我需要显示整个三个属性而不是一个属性。

我需要选择多个类似的标签。

请帮助解决此问题。

提前致谢

最佳答案

我认为您需要将html更改为

<input type="text" ng-model="selectedStuff"
typeahead="stuff as stuff.name + ' ' +stuff.desc + ' ' + stuff.title for stuff in stuffs | filter:{name: $viewValue, desc: $viewValue}"/>

关于javascript - Angular ui-bootstrap提前选择多个,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29789542/

10-10 00:49