gpt4 book ai didi

javascript - Angularjs 搜索整个 HTML

转载 作者:行者123 更新时间:2023-12-03 11:03:26 24 4
gpt4 key购买 nike

我正在尝试创建一个搜索功能,该功能将突出显示 Android 应用程序上的特定文本(使用 angularjs 的 Ionic/Cordova)。

从我引用的所有示例代码中,我可以找到如下所示的内容:

<div ng-init="friends = [{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}]"></div>

Search: <input ng-model="searchText">
<table id="searchTextResults">
<tr><th>Name</th><th>Phone</th></tr>
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
</tr>
</table>
<hr>

Any: <input ng-model="search.$"> <br>
Name only <input ng-model="search.name"><br>
Phone only <input ng-model="search.phone"><br>
Equality <input type="checkbox" ng-model="strict"><br>
<table id="searchObjResults">
<tr><th>Name</th><th>Phone</th></tr>
<tr ng-repeat="friendObj in friends | filter:search:strict">
<td>{{friendObj.name}}</td>
<td>{{friendObj.phone}}</td>
</tr>
</table>

有没有一种方法可以搜索整个 HTML 文档,而不仅仅是像上面那样搜索数组?

最佳答案

嘿,这很有趣......

无论如何都遇到了:http://www.quora.com/How-does-the-Search-function-in-a-browser-CTRL+F-work其中表示它使用 Knuth-Morris-Pratt 算法。

另外,如果您想使用 native 浏览器搜索功能:对于 Android:使用 webview's native function对于 IOS:您还可以使用 webview,并进行 js 调整。 Check this outthis to search exclusive for pdfs

在Javascript中:使用window.find()方法在当前的per this article中搜索关键字

祝你好运,希望你在这里找到你要找的东西。

关于javascript - Angularjs 搜索整个 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27971333/

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