I'm experiencing an issue with my component not appearing when I inject UserService, but it works fine when I remove the service from the component.
Here is the code snippet for providers in @NgModule:
providers: [
UserService,
{
provide:AuthServiceConfig,
useFactory: getAuthServiceConfigs
}
],
And here is the code for the UserService:
@Injectable()
export class UserService {
API_URL = environment.apiUrl;
constructor(private http: HttpClient) { }
getAll() {
return this.http.get<User[]>(this.API_URL+"getAllUsers");
}
}
Lastly, here is the component code where the issue arises:
export class UserRegistrationComponent implements OnInit {
registerForm: FormGroup;
submitted = false;
newUser;
userService: UserService;
constructor(
userService: UserService
)
{
config.backdrop = 'static';
config.keyboard = false;
this.userService=userService;
}
ngOnInit() {
this.registerForm = this.formBuilder.group({
emailId: ['', Validators.required],
firstName: ['', Validators.required],
lastName: ['', Validators.required],
password: ['', [Validators.required, Validators.minLength(8)]]
});
}
}