Having trouble importing a method into my Angular component.
An error keeps popping up:
Property 'alerta' does not exist on type 'typeof PasswordResetService'. any
I've double-checked the code and everything seems to be in order!
The issue arises in the password-reset.component.ts file where I'm trying to call that method.
import { PasswordResetService } from './password-reset.service';
@Component({
selector: 'app-password-reset',
templateUrl: './password-reset.component.html',
styleUrls: ['./password-reset.component.css']
})
export class PasswordResetComponent implements OnInit {
modalRef: BsModalRef;
constructor(private modalService: BsModalService) { }
openAlertModal() {
PasswordResetService.alerta("Title", "Message").subscribe((answer) => {});
}
The problem lies within the openAlertModal() method...
If you review the PasswordResetService, everything appears to be fine:
export class PasswordResetService {
BsModalRef: BsModalRef;
constructor(private BsModalService: BsModalService) { }
public alerta(title: string, message: string) : Observable<string> {
const initialState = {
title,
message,
};
this.BsModalRef = this.BsModalService.show(AlertModalComponent, { initialState });
return new Observable<string>(this.getAlertSubscriber());
}
The alerta() method is definitely there!
Can anyone offer assistance with this?
Thank you!.