如何在角度js中搜索和突出显示?

我有一个div,其中我有一些争论。我需要从该div搜索文本并突出显示该单词(使用css类)。接下来它搜索下一个单词出现和上一次出现。 我可以在jquery作为小提琴中的例子http://jsfiddle.net/3MVNj/5/你能建议我将如何在角js中实现这一点吗? plunker http://plnkr.co/edit/V805fEjJAUbAZIuafJcW?p=preview

          .highlightedText { background: yellow; }   
hello I need to search text from the contend .On click of search it search the first word.
var app=angular.module('app',[]); app.controller("contr",function($scope){ $scope.searchFirst=function(){ alert('search First text') } $scope.nextSearch=function(){ alert('nextSearch') } $scope.preSearch=function(){ alert('preSearch') } });

有没有办法搜索filter?

您可以使用旧的搜索算法,例如: http : //plnkr.co/edit/As9iyCVtMMNH7lyprJA9?p = preview

增加的是

  

示例搜索,仅转发(prev实现而非AngularJS相关)(请参阅运行示例的链接):

尝试搜索“sear”…仅测试该单词… =)

 app.controller("contr",function($scope){ var searcher = new Searcher(); var div = angular.element(document.getElementById('content')); $scope.searchFirst=function(str){ searcher.setOffset(0); searcher.setContent(div.text()); div.html(searcher.search(str)); } $scope.nextSearch=function(){ div.html(searcher.search()); } $scope.preSearch=function(){ // you implement } });