User is a component which I created and category + profileColor are Properties of the component:
<ScrollView>
<StackPanel>
<Each Items="{users}">
<User category="{category}" profileColor="{getProfileColor}"/>
</Each>
</StackPanel>
</ScrollView>
I would like to set the profileColor in respect of the category. So if the user is in category=1 then it should be red, and if he is in 2 then it should be blue for example. Every user in users has a “category” entry in the database.
getProfileColor looks like this:
function getProfileColor(args){
console.log("category should be inside here: " + JSON.stringify(args.data));
switch(args.data.category)
{
case 1:
return[1,1,1,1];
break;
case 2:
return[0,0,0,1];
break;
}
}
module.exports = {
getProfileColor: Observable(getProfileColor)
};
But somehow it seems there are no arguments because I get:
LOG: Name: TypeError
Error message: undefined is not an object (evaluating 'args.data')