I try to take a whole collection from my MongDB database as an array and use the documents in it as array elements, and also use the array's properties(such as its length)
I am sure that I take the collection as an array correctly (i.e. I can print the documents from my console) but when I try to assign its length to a number variable it returns the following error:
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined at new DashboardComponent (http://localhost:4200/main.bundle.js:300:36) at new Wrapper_DashboardComponent (/AppModule/DashboardComponent/wrapper.ngfactory.js:7:18) at CompiledTemplate.proxyViewClass.View_DashboardComponent_Host0.createInternal (/AppModule/DashboardComponent/host.ngfactory.js:15:34) at CompiledTemplate.proxyViewClass.AppView.createHostView (http://localhost:4200/vendor.bundle.js:82921:21) at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (http://localhost:4200/vendor.bundle.js:83377:52) at ComponentFactory.create (http://localhost:4200/vendor.bundle.js:44314:25) at ViewContainerRef_.createComponent (http://localhost:4200/vendor.bundle.js:61906:62) at RouterOutlet.activate (http://localhost:4200/vendor.bundle.js:67747:40) at ActivateRoutes.placeComponentIntoOutlet (http://localhost:4200/vendor.bundle.js:25277:16) at ActivateRoutes.activateRoutes (http://localhost:4200/vendor.bundle.js:25244:26) at http://localhost:4200/vendor.bundle.js:25180:58 at Array.forEach (native) at ActivateRoutes.activateChildRoutes (http://localhost:4200/vendor.bundle.js:25180:29) at ActivateRoutes.activate (http://localhost:4200/vendor.bundle.js:25154:14) at http://localhost:4200/vendor.bundle.js:24714:22
Thanks in advance!