Ionic-v4 service

#1

hi guys, could anyone help me fix this error?

core.js:15714 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[RegisterPage -> AuthService]:
StaticInjectorError(Platform: core)[RegisterPage -> AuthService]:
NullInjectorError: No provider for AuthService!
Error: StaticInjectorError(AppModule)[RegisterPage -> AuthService]:
StaticInjectorError(Platform: core)[RegisterPage -> AuthService]:
NullInjectorError: No provider for AuthService!
at NullInjector.push…/node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8894)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push…/node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push…/node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveNgModuleDep (core.js:21120)
at NgModuleRef_.push…/node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:21809)
at resolveNgModuleDep (core.js:21120)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17280)
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)

my authService

import { Injectable } from '@angular/core';
import { FirebaseService } from './firebase.service';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})

export class User {
  name: string;
  email: string;

  constructor(name: string, email: string) {
    this.name = name;
    this.email = email;
  }
}


export class AuthService {

  constructor(public firebaseService: FirebaseService) { }
}

my register page

import { Component, OnInit } from '@angular/core';
import { Validators, FormBuilder } from '@angular/forms';

import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';

@Component({
  selector: 'app-register',
  templateUrl: './register.page.html',
  styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {
 

  constructor(private formBuilder: FormBuilder,
    private authService: AuthService,
    private router: Router) {}
}

thankyou.

#2

Did you import authservice into app.module? If you missed it, that could be the issue.

1 Like