it is quite handy to have Object.keys()
available in my template via objectKeys = Object.keys;
in my .ts file.
I can easily output the number of properties in an object (objectKeys(foo).length
) or use *ngFor
with my objects (*ngFor="let key of objectKeys(foo) ... {{ foo[key] }}
).
Right now I copy the objectKeys = Object.keys;
line to all my .ts files.
Is there a way to expose this method to all my templates easily?
(Bonus question: Is there a better way to do what I do here? Somehow this feels… dirty )