Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Property 'darkModeService' does not exist on type 'LoanComponent'

i am trying to make my angular app runt with dark theme, and i have set it up correctly but it doesent work

Code:

 constructor(private bookService: BookService, private categoryService: CategoryService,  private formBuilder: FormBuilder, darkModeService: DarkModeService) {}
  range = new FormGroup({
    fromDate: new FormControl('', Validators.required),
    toDate: new FormControl('', Validators.required)
  });


darkMode$: Observable<boolean> = this.darkModeService.darkMode$;// and here

  ngOnInit(): void {
    this.dateRangeForm = this.formBuilder.group({
      fromDate: new FormControl('', Validators.required),
      toDate: new FormControl('', Validators.required)
    });

  }
  onToggle(): void {
    this.darkModeService.toggle();//error happens here
  }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Could you please say where is you DarkModeService provided?

Beside this, please try the following in the constructor of your class (added private beside darkModeService: DarkModeService):

constructor(private bookService: BookService, 
            private categoryService: CategoryService,  
            private formBuilder: FormBuilder, 
            private darkModeService: DarkModeService) {} // add private here
  range = new FormGroup({
    fromDate: new FormControl('', Validators.required),
    toDate: new FormControl('', Validators.required)
  });


darkMode$: Observable<boolean> = this.darkModeService.darkMode$;// and here

  ngOnInit(): void {
    this.dateRangeForm = this.formBuilder.group({
      fromDate: new FormControl('', Validators.required),
      toDate: new FormControl('', Validators.required)
    });

  }
  onToggle(): void {
    this.darkModeService.toggle();//error happens here
  }

Instead of private, you can use public or readonly as well. Since im not aware of your project, im not sure which one fits you the best.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading