Skip to content

Instantly share code, notes, and snippets.

@adhamankar
Created May 4, 2015 11:30
Show Gist options
  • Save adhamankar/fcc0573b82f8ea7b43cb to your computer and use it in GitHub Desktop.
Save adhamankar/fcc0573b82f8ea7b43cb to your computer and use it in GitHub Desktop.
Angular popup service
export class ClientContainerCtrl {
public static $inject = ["$scope", "$http", "$state", "ApiConfig", "popup"];
constructor(public $scope: ng-IScope, public $http: ng.IHttpService
, public $state: ng.ui.IStateService, public ApiConfig: IApiConfig, public popup: Common.Services.ModalService
) {
super($scope, $http);
this.init();
}
public showEditor = (record: DoneCriteria) => {
var me = this;
this.popup.openModal({
controller: ClientPopupCtrl,
templateUrl: "app/ClientPopupCtrl.tpl.html",
resolve: {
container: () => me.popup
}
},
(success) => {
console.log("success", success);
});
};
export class ClientPopupCtrl extends Common.Framework.PopupBaseCtrl {
public static $inject = ["$scope", "$http", "$state", "container"];
constructor(public $scope: Common.Framework.IControllerScope<DoneCriteriaEditorCtrl>, public $http: ng.IHttpService
, public $state: ng.ui.IStateService, public container: Common.Framework.IModalContainer
) {
super($scope, container);
this.init();
}
/// <reference path="../../_references.ts" />
module Common.Framework {
"use strict";
export interface IModalContainer {
modalInstance: ng.ui.bootstrap.IModalServiceInstance;
openModal(settings: ng.ui.bootstrap.IModalSettings, onClosingModal: any): void;
closeModal(success? : any): void;
}
}
/// <reference path="../../_references.ts" />
module Common.Framework {
"use strict";
export class PopupBaseCtrl extends BaseCtrl {
public static $inject = ["$scope", "container"];
constructor($scope: IControllerScope<any>
, public container: Common.Framework.IModalContainer
) {
super($scope);
}
public closeModal = (success?: any): void => {
if (this.container !== null || this.container !== undefined) {
this.container.closeModal(success);
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment