need some help, for the life of me I can't get this to work. I'm trying to loop through an array which is within a config value and then trigger another function within the service I created, but I get an error
TypeError: Cannot read property 'registerToken' of undefined
Is there not a better way to do this it feels very clunky?
CampaignService.ts
import { ServerConfig } from "../core/ServerConfig";
declare var config: ServerConfig;
export class CampaignService {
static $inject = ["localStorageService"];
constructor(
public localStorageService: angular.local.storage.ILocalStorageService
) {
}
launchCampaign(campaignToken: string) {
if (campaignToken) {
config.campaigns.forEach(function (data) {
if (campaignToken == data.title) {
if (data.enabled) {
this.registerToken(campaignToken);
}
}
});
}
};
registerToken(campaignToken: string) {
}
}