When getting this error:
errorStack: TypeError: Cannot read property 'length' of undefined
at get (https://prodtest.mudano.com/core/tasks.data.service.js:9:37)
A solution to this type of error where properties are deply nested in object sub properties, and you're not sure if the property is set up yet is to use _.get
To convert:
if ($rootScope._global.tasks.length > 0)
into:
if(_.get($rootScope, '_global.tasks.length' && $rootScope._global.tasks.length > 0)) {
// do something
}
and therefore swallow any errors generated when accessing tasks length
#Warning
Be careful though, as sometimes not having properties setup is a good thing and tells us something is wrong elsewhere