Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
¿Por qué al usar la función 'registrarse' aparece "No todas las rutas de código devuelven un valor"?

No soy una persona técnicamente, solo un principiante. ¿Podrias ayudarme por favor? Realmente no entiendo qué tipo de problema tengo. Estoy usando la función 'SingUp' y tengo una descripción de error de este tipo en mi VSC: " (método) RegComponent.signUp(): falso | indefinido No todas las rutas de código devuelven un valor". ¿Qué estoy haciendo mal? Traté de escribir return: false después del último bloque "else if". Pero algo sucedió y todo mi código a continuación se volvió transparente.

Ahí está mi reg.component.ts

 import { Component, OnInit } from '@angular/core'; import { FlashMessagesService } from 'angular2-flash-messages'; import { UnsubscriptionError } from 'rxjs'; import { AuthService } from '../auth.service'; import { Router } from '@angular/router'; @Component({ selector: 'app-reg', templateUrl: './reg.component.html', styleUrls: ['./reg.component.scss'] }) export class RegComponent implements OnInit { name!: string login!: string email!: string password!: string constructor( private _flashMessagesService: FlashMessagesService, private authService: AuthService, private router: Router ) { } ngOnInit(): void { } signUp() { const user = { name: this.name, login: this.login, email: this.email, password: this.password, } if(!user.name) { this._flashMessagesService.show('Enter your name!', { cssClass: 'alert-danger', timeout: 3000 }); return false } else if(!user.login) { this._flashMessagesService.show('Enter your login!', { cssClass: 'alert-danger', timeout: 3000 }); return false } else if(!user.email) { this._flashMessagesService.show('Enter your email!', { cssClass: 'alert-danger', timeout: 3000 }); return false } else if(!user.password) { this._flashMessagesService.show('Enter your password!', { cssClass: 'alert-danger', timeout: 3000 }); return false } this.authService.registerUser(user).subscribe( data => { if (!data.success) { this._flashMessagesService.show(data.msg, { cssClass: 'alert-danger', timeout: 3000 }); this.router.navigate(['/reg']) } else { this._flashMessagesService.show(data.msg, { cssClass: 'alert-success', timeout: 3000 }); this.router.navigate(['/auth']) } }) } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!