First things first, let's talk about my class:
class FavoriteFooBar {
...
isPreferred: boolean = false;
constructor() {
this.isPreferred = false;
}
}
Using a utility library called Uniquer, I arrange a list of FavoriteFooBar
instances to prioritize favorites at the top:
this.favFBBars = Uniquer.orderBy(this.favFBBars, ['isPreferred', 'name'], ['desc', 'asc']);
After marking an item as favorite and checking my console log, it shows:
https://i.sstatic.net/4ogPm.jpg
Note that #3 does not have the isPreferred property...
It seems like Lodash doesn't sort properly when isPreferred
isn't explicitly set. Is there a way to always display this property, even if it's unused/unset/false?
I've already tried:
- Initializing the property to false in the class
- Setting the property to false in the constructor of the class
- Iterating through this.favFBbars
in the component and setting them all to false
- Implementing an interface for FavoriteFooBar