Material: md-highlight-text should be able to hightlight one of multiple terms

Created on 28 Jun 2016  路  1Comment  路  Source: angular/material

Hello,

I'm using md-highlight-text to show search results and when the user searches for : "_term1 term2_", the system only highlights the phrase "_term1 term2_".

What I would like is a way to highlight "_term1_", "_term2_" and "_term1 term2_". I don't think this is possible right now and it could be very useful if you want to handle full-text search results.

I have tried to replace my searched terms with a pipe :
md-highlight-text="getHighlightedText()" md-highlight-flags="i"

$scope.getHighlightedText = function(){
    var result = $scope.highlightedText ;
    if (result != null && result.indexOf(" ") != -1)
        result = result.replaceAll(" ", "|");
    return result;
}

Unfortunately, the text is sanitized so it doesn't work.

Maybe if the returned value for the md-highlight-text is an array, we can support this case ?

>All comments

Will not fix in ngMaterial v1.x: deprecated.

Was this page helpful?
0 / 5 - 0 ratings