I'm currently facing some challenges using classes in Angular to simplify my coding process. So far, I haven't been able to get it to work properly. Below is the code snippet I'm working with and the error message that pops up:
import { WizardData } from '../models/wizard-data';
export class WizardPage {
private type: String;
private data: WizardData;
public getType(){
return this.type;
}
public setType(type: String){
this.type = type;
}
public getData(){
return this.data;
}
public setData(data: WizardData){
this.data = data;
}
}
and
import { Component, OnInit } from '@angular/core';
import { WizardPage } from '../../shared/models/wizard-page';
@Component({
selector: 'app-wizard-base',
templateUrl: './wizard-base.component.html',
styleUrls: ['./wizard-base.component.scss']
})
export class WizardBaseComponent implements OnInit {
wizardPage: WizardPage = new WizardPage();
wizardPage.setType("address");
constructor() { }
ngOnInit() {}
}
This line causes an error:
wizardPage.setType("address");
The error messages are as follows (CLI):
ERROR in src/app/wizard/wizard-base/wizard-base.component.ts(14,13): error TS1005: ';' expected.
src/app/wizard/wizard-base/wizard-base.component.ts(14,22): error TS1003: Identifier expected.
In Visual Studio Code, the notifications are:
[ts] Duplicate identifier 'wizardPage'.
[ts] Subsequent property declarations must have the same type. Property 'wizardPage' must be of type 'WizardPage', but here has type 'any'.
(property) WizardBaseComponent.wizardPage: WizardPage
If anyone knows what could be causing this issue, I would greatly appreciate your input!
Thank you!