This is the code I have:
export class CustomToast implements OnInit {
toastTypeGroup: string;
message: string;
title: string;
showDuration= "300";
constructor(_toastTypeGroup: string, _message:string, _title: string ){
this.toastTypeGroup = _toastTypeGroup;
this.message = _message;
this.title = _title;
}
ngOnInit() {
**//Here's a possible solution**
**var _this = this;**
console.log(this.showDuration);
var ToastrDemo = function () {
var toastr: any = (<any>window).toastr;
var k, m = -1, f = 0;
var t = function () {
var t, o,
//toastTypeGroup
e = this.toastTypeGroup,
//message
n = this.message,
//title
a = this.title,
//showDuration
i = this.showDuration,
};
return { init: function () { t() } }
}();jQuery(document).ready(function () { ToastrDemo.init() });
}
}
I am facing an issue where I need to access member values from my class named CustomToast within a JavaScript function called var t = function () {...}.
The problem is that I cannot retrieve typescript class member values inside a JavaScript Function. For example, the member "toastTypeGroup" is not accessible within my function. This presents a major challenge.
I would appreciate any help on this matter. Thank you in advance.