Created
July 7, 2016 15:10
-
-
Save KerryRitter/6607b1429fe8abccf6d31d252c649f54 to your computer and use it in GitHub Desktop.
ComponentModalService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ComponentModalService { | |
public static $inject = ["$uibModal"]; | |
private _modalInstance: ng.ui.bootstrap.IModalServiceInstance; | |
public constructor( | |
private _modalService: ng.ui.bootstrap.IModalService | |
) { | |
} | |
public open(component: ng.IComponentOptions, resolve: any): ng.IPromise<any> { | |
const options: ng.ui.bootstrap.IModalSettings = { | |
controller: component.controller, | |
controllerAs: "$ctrl", | |
backdrop: "static", | |
size: "lg", | |
resolve: resolve | |
}; | |
if (!_.isEmptyOrWhiteSpace(component.template)) { | |
if (_.isString(component.template)) { | |
options.template = component.template as string; | |
} else { | |
options.template = (component.template as Function)(); | |
} | |
} | |
if (!_.isEmptyOrWhiteSpace(component.templateUrl)) { | |
if (_.isString(component.template)) { | |
options.templateUrl = component.templateUrl as string; | |
} else { | |
options.templateUrl = component.templateUrl as () => string; | |
} | |
} | |
this._modalInstance = this._modalService.open(options); | |
return this._modalInstance.result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment