util_srv.ts 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ///<reference path="../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import _ from 'lodash';
  4. import $ from 'jquery';
  5. import coreModule from 'app/core/core_module';
  6. import appEvents from 'app/core/app_events';
  7. export class UtilSrv {
  8. /** @ngInject */
  9. constructor(private $rootScope, private $modal) {
  10. }
  11. init() {
  12. appEvents.on('show-modal', this.showModal.bind(this), this.$rootScope);
  13. }
  14. showModal(options) {
  15. if (options.model) {
  16. options.scope = this.$rootScope.$new();
  17. options.scope.model = options.model;
  18. }
  19. var modal = this.$modal({
  20. modalClass: options.modalClass,
  21. template: options.src,
  22. templateHtml: options.templateHtml,
  23. persist: false,
  24. show: false,
  25. scope: options.scope,
  26. keyboard: false,
  27. backdrop: options.backdrop
  28. });
  29. Promise.resolve(modal).then(function(modalEl) {
  30. modalEl.modal('show');
  31. });
  32. }
  33. }
  34. coreModule.service('utilSrv', UtilSrv);