Skip to content

Instantly share code, notes, and snippets.

@bioyeneye
Forked from adhamankar/ClientContainerCtrl.ts
Created October 18, 2017 10:35
Show Gist options
  • Save bioyeneye/265b320f17fcc374b1d7920fd2251b8b to your computer and use it in GitHub Desktop.
Save bioyeneye/265b320f17fcc374b1d7920fd2251b8b 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