Currently, I am developing a single page application using Angular and TypeScript. I am facing an issue with updating the parameter value (_isShowFirst) of the controller inside a promise function. It seems like nothing is recognized within the promise block. The service function returns a Promise as well. Below is my controller code:
module CreditCardActivation {
'usestrict';
export class CreditCardActivationController {
public _isShowFirstStep: boolean;
public _isShowSecondStep: boolean;
public _errorMessage: string;
constructor() {
this._isShowFirstStep = true;
this._isShowSecondStep = false;
}
activate = () => {
this.ActivationService.activate(somedata).then((result) => {
//-------Problem is here ----------//
this._isShowFirst = true
});
}
}
angular.module('Activation').controller('ActivationController', ActivationController)
}
This is the activation function in my service:
activate = (data:ActivationRequest): ng.IPromise<ActivationResponse> =>{
var response = this.httpService.get("someurl").then({
return JSON.parse(JSON.stringify(response.data));
});
return (response);
}
Do you have any idea on how to solve this issue? Any help is appreciated. Thank you!