我怎样才能用 ng-repeat 制作这个过滤器

how can i make this filter with ng-repeat

我编写了一个社交媒体应用程序。我的个人资料页面中的个人资料菜单有问题。我希望它根据某些情况成为可见的菜单项。我确实将菜单项放在这样的数组中;

$scope.menuitems = [
    {id : "1", name : "Message", show : "other", url : ""},
    {id : "2", name : "Follow", show : "other", url : ""},
    {id : "3", name : "Followers", show : "all", url : ""},
    {id : "4", name : "About", show : "all", url : ""},
    {id : "5", name : "Statistics", show : "all", url : ""},
    {id : "6", name : "Edit", show : "own", url:""}
];

İf 可见配置文件是用户自己的配置文件,我想打印具有 'show' 值 'own' 的项目。如果可见配置文件是另一个用户的配置文件,我想打印 'show' 值 'other' 的项目。我想在每个场景中打印 'show' 值 'all' 的项目。我为此在互联网上做了一些研究,但我想我还没有找到合适的词。我是如何在 Angularjs?

上用 ng-repeat 做这个的

创建自定义过滤器

    $scope.conditionVar = 'own'; //this will change depending on what profile

    angular.module('myFilters', []).
  filter('profilefilter', function() {
    return function(items, condition) {
      var out = [];
      for (var i in items) {
        var item = items[i];
        if (item.show === 'all' || item.show === condition) {
            out.push(item);
        }
      }
      return out;
    }
  });
    <li ng-repeat="menuitem in menuitems | profilefilter:conditionVar">{{menuitem}}</li>

这是工作演示 - https://jsfiddle.net/0o7ewpgd/1/