exact filter in angular

前端 未结 6 1370
天命终不由人
天命终不由人 2020-11-29 12:10

In Angular, is there a way to modify the filter such that it only returns exact matches?

Example:

var words = [
    {   title: \"ball\"   },
    {            


        
6条回答
  •  半阙折子戏
    2020-11-29 12:41

    Try this :

    var words = [
        {   title: "ball"   },
        {   title: "wall"   },
        {   title: "all"    },
        {   title: "alloy"  }
    ];
    
    var wordsFiltered = filter('filter')
    ( 
        words, 
        { 
            'title': 'all'
        },
        true
    );
    

提交回复
热议问题