简体   繁体   中英

how to ng-repeat a scope function in angular

So I have a scope function below that returns uniqueUsers . If I want to output the text in HTML using ng-repeat, how do I go about doing this?

// update filter functions
$scope.updateFilter = function (start, end) {
  // console.log(start.unix());
  thisMonthUsers = [];
  records.forEach(function (entry) {
    var entryStart = entry.f[3].__text / 1000;
    var entryEnd = entry.f[4].__text / 1000;
    if (!(entryEnd < start.unix() || entryStart > end.unix())) {
      thisMonthUsers.push(entry.f[1].__text);
    }
  });
  var uniqueUsers = thisMonthUsers.filter(Unique); // unique
    return uniqueUsers;
}

So far I have tried this but it doesn't work:

<div class="panel-body">
  <ul>
    <li ng-repeat="uniqueUsers in updateFilter">{{ uniqueUsers() }}</li>
  </ul>
</div>

Following code could do the trick:

<div class="panel-body">
    <ul>
        <li ng-repeat="user in users = uniqueUsers() | filter">...</li>
    </ul>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM