Currently, I have code that selects words in a list if there is a match with this array.
$scope.arrayFilter=["is","mom","beautifull",'beer'];
I no longer need this piece of code. I only need to select the text of the ".marque" class from the array, without losing the effect of the library that performs the "marquee" effect. How can i do this?
https://jsfiddle.net/mafa4hro/
<div ng-app="testApp" ng-controller="testCtrl">
<li ng-repeat="item in data ">
<span ng-bind-html="item.title | highlight:arrayFilter"></span>
</li>
<div class='marquee' >mom is beautifull</div>
</div>
var app = angular.module('testApp',[]);
app.controller('testCtrl',function($scope){
$scope.arrayFilter=["mom","is","beautifull",'beer'];
$scope.data = [{
title: "mom is beautifull"
}, {
title: "my mom is great"
}, {
title: "I hate the matematics"
}];
//marquee effect
$('.marquee').marquee({
duration: 5000
});
$('.marquee')
.bind('finished', function(){
console.log('finish')
$(this).html('If it works, i need a beer')
//Apply marquee plugin again
.marquee({
duration: 5000,
})
})
});
app.filter('highlight', function($sce) {
return function(text, arrayFilter) {
angular.forEach(arrayFilter, function(key, value) {
if (text.includes(key)) {
text = text.replace(new RegExp(key, 'gi'), '<spanclass="highlightedText">$&</span>')
}
})
return $sce.trustAsHtml(text);
}
});
source
share