我有一个自定义数据类型Message
:
function Message(body, author, date) {
this.body = body;
this.author = author;
this.date = date;
this.stars = [];
}
Message.prototype.hasStars = function() {
return this.stars.length !== 0;
};
我也在重复这些消息的数组:
<li ng-repeat='message in messages | orderBy:"-stars.length"'>…</li>
我怎样才能添加一个过滤器来调用它message.hasStars()
?我尝试了以下方法,但都没有效果:
message in messages | filter:message.hasStars() | orderBy:"-stars.length"
message in messages | filter:message:hasStars() | orderBy:"-stars.length"
message in messages | filter:message.hasStars | orderBy:"-stars.length"
message in messages | filter:message:hasStars | orderBy:"-stars.length"