Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
Taking a whole collection from MongoDB and use its length in Angular2

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!

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda