I have an AngularJS service written in JavaScript and i would like to convert this to TypeScript. The Javascript version returns a function immediately. Why would it do this and how would I implement this in TypeScript?
JavaScript
Geisha.service("loginModal", ["$uibModal", "$rootScope", function ($uibModal: angular.ui.bootstrap.IModalService, $rootScope: ICustomRootScopeService) {
function assignCurrentUser(user: User) {
$rootScope.currentUser = user;
return user;
}
return function () {
var instance = $uibModal.open({
templateUrl: "/Angular/Security/Views/loginTemplate.html",
controller: "loginModalCtrl"
});
return instance.result.then(assignCurrentUser);
}}]);
TypeScript
In TypeScript I have only gone as far as creating the constructor and one of the methods but not sure how to implement the immediate return function
module G.Services {
export class LoginModal {
$rootScope: ICustomRootScopeService;
$uibModal: angular.ui.bootstrap.IModalService;
static $inject = ["$rootScope", "$uibModal"];
constructor($rootScope: ICustomRootScopeService, $uibModal: angular.ui.bootstrap.IModalService) {
this.$rootScope = $rootScope;
this.$uibModal = $uibModal;
}
assignCurrentUser(user: User): User {
this.$rootScope.currentUser = user;
return user;
}
}
Geisha.service("loginModal", LoginModal);}