TypeScript Version: 2.0.10 / 2.0.2 / 2.1.5
Code
http://plnkr.co/edit/ZQONYB5oaLhO8aVRaLjE?p=preview
this.service.getData().subscribe(
function(x) {
this.data = x;
});
this.service.getData().subscribe(
(x) => {
this.data = x;
});
// transpiled output
App.prototype.ngOnInit = function () {
this.service.getData().subscribe(function (x) {
this.data = x;
});
};
App.prototype.ngOnInit = function () {
var _this = this;
this.service.getData().subscribe(function (x) {
_this.data = x;
});
};
Expected behavior:
It should make no difference between function or fat arrow function.
Actual behavior:
Missing this reference. var _this = this; for the function
// transpiled output
App.prototype.ngOnInit = function () {
var _this = this;
this.service.getData().subscribe(function (x) {
_this.data = x;
});
};
TypeScript Version: 2.0.10 / 2.0.2 / 2.1.5
Code
http://plnkr.co/edit/ZQONYB5oaLhO8aVRaLjE?p=preview
Expected behavior:
It should make no difference between function or fat arrow function.
Actual behavior:
Missing this reference.
var _this = this;for the function