I've created a custom data type called 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;
};
Currently, I am iterating over an array of these messages:
<li ng-repeat='message in messages | orderBy:"-stars.length"'>…</li>
Is there a way to add a filter that utilizes the message.hasStars()
method? I attempted several methods below but none seemed to work as expected:
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"