gpt4 book ai didi

javascript - Angular ui-bootstrap typeahead 选择多个

转载 作者:行者123 更新时间:2023-11-29 21:49:56 26 4
gpt4 key购买 nike

是否可以在搜索一个人时显示与该人相关的所有内容。并且还必须选择多个 Angular 色。

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

<!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"
}
]
}

这里当我搜索时它只显示 name 或 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 typeahead 选择多个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29789542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com