Nebular: can't custom UI login component

Created on 14 Feb 2019  ·  11Comments  ·  Source: akveo/nebular

Issue type

I'm submitting a ...

  • [X ] bug report
  • [ ] feature request

Issue description

Current behavior:
Error: Can't resolve all parameters for NgxLoginComponent: ([object Object], ?, [object Object], [object Object]).

Expected behavior:
I try to extend NgLoginComponent with a constructor inside

Related code:

import {ChangeDetectorRef, Component, Injectable} from '@angular/core';
import {NbAuthService, NbLoginComponent} from '@nebular/auth';
import {AuthService} from '../auth.service';
import {Router} from '@angular/router';


@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
})

export class NgxLoginComponent extends NbLoginComponent {
  constructor(service: NbAuthService, options: {}, cd: ChangeDetectorRef, routes: Router){
    super(service, options, cd, routes);
  }
}

The issue appear only if I use constructor.
I need to use a constructor because I need implement my own auth service in this component.

Other information:

npm, node, OS, Browser

<!--
Node, npm: v11.6.0, 6.5.0-next.0
OS: macOS Mojave (10.14.2)
Browser: Chrome  72.0.3626.96 
-->

Most helpful comment

Hi @xeti34. You need to use @Inject(NB_AUTH_OPTIONS) protected options as a second parameter of constructor, instead of options: {}. See dependency-injection in angular docs.

All 11 comments

Hi @xeti34. You need to use @Inject(NB_AUTH_OPTIONS) protected options as a second parameter of constructor, instead of options: {}. See dependency-injection in angular docs.

@yggg it's working !!!! thank's 👍

Has anyone tried this on Nebular 5?

constructor(service: NbAuthService,
    @Inject(NB_AUTH_OPTIONS) protected options: {},
    cd: ChangeDetectorRef, routes: Router){
    super(service, options, cd, routes);
  }

I also tried that, but I get the same _"Can't resolve all parameters"_ error.

@ukikalix

Here's my answer as posted on SO

@ukikalix

Here's my answer as posted on SO

The ctor always marks me the arguments it expects to receive, specifically 4 arguments, idk but I send them, and in the same way I get the error that in previous versions, this solved it

your Login/Logout component inherits from Nebular Auth Component.

The parent should also inject the desired services into its constructor in
that the arguments match with those of the inherited class.

On Tue, Jun 9, 2020 at 8:39 AM ukikalix notifications@github.com wrote:

@ukikalix https://github.com/ukikalix

Here's my answer
https://stackoverflow.com/questions/61686673/i-cannot-find-how-i-can-access-di-properties-from-a-child-class/61699122#61699122as
posted on SO

The ctor always marks me the arguments it expects to receive, specifically
4 arguments, idk but I send them, and in the same way I get the error that
in previous versions, this solved it


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/akveo/nebular/issues/1234#issuecomment-641040751, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AEJKSWGFSEJTWUZSXSLTMODRVXDHLANCNFSM4GXNUPNA
.

Well, I really do, it worked in version 4.x, but not in version 5.x.

Here is the code:

constructor(service: NbAuthService,
    @Inject(NB_AUTH_OPTIONS) protected options = {},
    cd: ChangeDetectorRef,
    router: Router) {
    super(service, options, cd, router);
  }

Then post your errors for further scrutiny

The same error "can't resolve all parameters for ownauthlogin component in login.component.ts: ([object object], ?, [object object], [object object])."

Show me the code for login.components.ts, Also, that for the class it implements.

Hi,
Whats works for me its to add the @Option() annotation

@Inject(NB_AUTH_OPTIONS) @Optional() public options

Hope its helps

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnsnow20087349 picture johnsnow20087349  ·  3Comments

dragonbane0 picture dragonbane0  ·  3Comments

rhajizadeh picture rhajizadeh  ·  3Comments

aqsdc1 picture aqsdc1  ·  3Comments

bnbs picture bnbs  ·  4Comments