I'm submitting a ...
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.
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
-->
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 SOThe 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
Most helpful comment
Hi @xeti34. You need to use
@Inject(NB_AUTH_OPTIONS) protected optionsas a second parameter of constructor, instead ofoptions: {}. See dependency-injection in angular docs.