From the above answeres, following did not work or less preferable:
(previous_info | json) != '{}' works only for {} empty case, not for null or undefined caseObject.getOwnPropertyNames(previous_info).length also did not work, as Object is not accessible in the templatethis.objectLength = Object.keys(this.previous_info).length !=0;I would not like to create a dedicated function
isEmptyObject(obj) {
return (obj && (Object.keys(obj).length === 0));
}
Solution: keyvalue pipe along with ?. (safe navigation operator); and it seems simple.
It works well when previous_info = null or previous_info = undefined or previous_info = {} and treats as falsy value.
keyvalue - Transforms Object or Map into an array of key value pairs.
?. - The Angular safe navigation operator (?.) is a fluent and convenient way to guard against null and undefined
DEMO: demo with angular 9, though it works for previous versions as well