Reputation: 618
I have a class.
export class DatabaseHelper {
public browserID : number;
private ConfigID = 17;
}
Now, in the same class I am trying to access the ConfigID
SetBrowserID() {
browser.getCapabilities().then(function (cap) {
this.browserID = new commFnctions.appdata().getBrowserIDFromBrowserName(cap.get('browserName'));
});
}
this is giving me error as:
TypeError: Cannot set property 'browserID' of undefined
Upvotes: 1
Views: 1357
Reputation: 123861
This is really the basic of a Typescript... use arrow function:
SetBrowserID() {
browser.getCapabilities()
//.then(function (cap) {
.then((cap) => {
this.browserID = new commFnctions
.appdata()
.getBrowserIDFromBrowserName(cap.get('browserName'));
});
}
Read more about it
Upvotes: 3