self.getNoteClass = function(status) {
return {
done: status,
pending: !status
};
};
I encountered such a usage in the book, the incoming parameter must be true or false, and then passing in true returns done, and false returns pending.
I would like to ask if this usage is a special usage in angularjs? I don’t understand, please give me some answers, thank you!
PS: The following example I wrote myself is a simpler and clearer way of use that I can understand.
self.getClassname = function(string) {
var obj = {
'1' : even,
'2' : odd
};
return obj[string];
};
I guess this is meant to be used in conjunction with the
ng-class
built-in directive, in which case, the classNamedone
will be applied to the element whenstatus
is true, and classNamepending
will be applied to the element otherwise.You may see the "Map Syntax Example" section in the document for
ng-class
for reference.