gpt4 book ai didi

Javascript/AngularJS 数组

转载 作者:行者123 更新时间:2023-11-28 08:06:55 25 4
gpt4 key购买 nike

我正在尝试创建一个应用程序,其中有多个位置,并且您开始输入位置名称,它会缩小搜索范围。我在使用这个数组时遇到问题。这是我的代码:

var getSiteLoc = function($scope) {
var SiteLocs
$scope.SiteLocs = [{
"name": "502 Nelson St, Greenville, MS 38701",
"visibility": "0",
"description": "502 Nelson St, Greenville, MS 38701",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-91.05636,33.415485,0"
}
}, {
"name": "242 Blackhawk Trace, Galena, IL 61036",
"visibility": "0",
"description": "242 Blackhawk Trace, Galena, IL 61036",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-90.319778,42.390862,0"
}
}, {
"name": "3747 Ocean Dr, Vero Beach, FL 32963",
"visibility": "0",
"description": "3747 Ocean Dr, Vero Beach, FL 32963",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-80.358248,27.659094,0"
}

现在我希望能够按名称查找这些内容,但似乎无法找到方法。感谢您的帮助。

最佳答案

请参阅此处http://jsbin.com/yodeg/1/edit?html,js,output

HTML:

 <input type="text" ng-model="search"/>
<ul>
<li ng-repeat="site in SiteLocs |filter : search ">{{site.name}}</li>

</ul>

js:

 $scope.SiteLocs = [
{
"name": "502 Nelson St, Greenville, MS 38701",
"visibility": "0",
"description": "502 Nelson St, Greenville, MS 38701",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-91.05636,33.415485,0"
}

}
,
{
"name": "242 Blackhawk Trace, Galena, IL 61036",
"visibility": "0",
"description": "242 Blackhawk Trace, Galena, IL 61036",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-90.319778,42.390862,0"
}
}
,
{
"name": "3747 Ocean Dr, Vero Beach, FL 32963",
"visibility": "0",
"description": "3747 Ocean Dr, Vero Beach, FL 32963",
"styleUrl": "#waypoint",
"Point": {
"coordinates": "-80.358248,27.659094,0"
}
}];


});

关于Javascript/AngularJS 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24698647/

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