Это мой код:
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() {
**//this is the 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() });
}
}
Моя проблема в том, что я хочу прочитать значения членов из моего класса CustomToast внутри моей JavaScript функции с именем vart = function () {...}.
Я не могу получить значение члена класса машинописного текста внутри JavaScript-функции.например, член "toastTypeGroup" недоступен, кроме моей функции Это большая проблема.
Заранее спасибо.