I am following a course that uses angular version 4 however I decided to use version 12.2.10 of angular CLI and version 14.18.1 of Node.
I created a 'contact.ts' model:
export class Contact{
private id:number;
private nom:string;
private prenom:string;
private email:string;
private tel:string;
private photo:string;
constructor(id:number,nom:string,prenom:string,email:string,tel:string,photo:string){
this.id = id;
this.nom = nom;
this.prenom = prenom;
this.email = email;
this.tel = tel;
this.photo = photo
}
}
and I'm trying to instantiate a new class of it here 'NewContactComponent.ts':
import { Component, OnInit } from '@angular/core';
import { Contact } from 'src/model/model.contact';
@Component({
selector: 'app-new-contact',
templateUrl: './new-contact.component.html',
styleUrls: ['./new-contact.component.css']
})
export class NewContactComponent implements OnInit {
contact:Contact=new Contact();
constructor() { }
ngOnInit(): void {
}
}
but impossible to do that. Here is the error message:
6 arguments expected, but 0 received.ts(2554)
model.contact.ts(10, 17): Aucun argument pour 'id' n'a été fourni.
(alias) new Contact(id: number, nom: string, prenom: string, email: string, tel: string, photo: string): Contact
import Contact