Ionic first app (Taking Photos with the Camera) errors

HI everybody, I’m new to Ionic and trying to build my first app as from here: Build Camera API for iOS, Android & Web | Ionic Capacitor Camera.
I first got an error in services/photo.service.ts and solved it modifying:

public async addNewToGallery() {


const addNewToGallery = async() => {

But next I can’t fix this error in

 ./src/app/tab2/ - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/tools/babel/webpack-loader.js):
[ng] SyntaxError: B:\Programming\VisualStudio\Ionic\photo-gallery\src\app\tab2\ Unexpected reserved word 'public'. (7:12)
[ng]    5 | import * as i1 from "../services/photo.service";
[ng]    6 | import * as i2 from "@ionic/angular";
[ng] >  7 | constructor(public, photoService, PhotoService);
[ng]      |             ^
[ng]    8 | { }
[ng]    9 | addPhotoToGallery();
[ng]   10 | {

and many other following errors depending on the first one (I guess…).
My services/photo.service.ts code is the following:

import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';

import { PhotoService } from '../services/photo.service';

constructor(public photoService: PhotoService) {}
  addPhotoToGallery() {  

  selector: 'app-tab2',
  templateUrl: '',
  styleUrls: [''],
  standalone: true,
  imports: [IonicModule, ExploreContainerComponent]

export class Tab2Page {

  constructor(public photoService: PhotoService) {  }


Please, may anyone help?
Thanks in advance.

Please check if these could be helpfull



Hi Techbinomial,
the first video, though it was only a similar topic, set me on the right path: I didn’t put the code into the class declaration!
Thanks a lot!

1 Like