-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
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;
});
};Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug