My code looked like this but now I put it into a Typescript class and it gives me an error saying that "can't read property role of undefined".
this.$http({
method: 'POST',
url: '/Token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: 'grant_type=password&username=' + encodeURIComponent(userName) + '&password=' + encodeURIComponent(password),
})
.success(function (data, status, headers, cfg) {
data.roles.split(':').forEach(function (v) {
this.data.role['is' + v] = true;
v == 'Test'
})
Do I have to code my function differently with Typescript ? I have two function in the success(), can I replace this with => ?